Reputation: 26018
I wonder, why doesn't this work:
object test {
def method1(a: Int) = println(a) // println a -- doesn't work either
method1 123
}
method1
takes only parameter, that is, it can be possible to omit parenthesis, can't it?
Upvotes: 1
Views: 89
Reputation: 14842
This is a conflict with postfix operation. Let's have a look at your example:
println a
The parser would interpret this as
println.a
It would be very confusing if you could write
println 123
(which is distinguishable, since 123
is not a valid method name), but now if you replace 123
by a variable holding the value, you'll get something like member a not found on println
.
Upvotes: 2