I read that if a method takes no argument and has no side-effects, parenthesis can be removed to improve readability (spartan implementation). So I can call following code
def withoutP = {
println(s"without p")
}
withoutP
Then I found this code which takes arguments but I can still call it without parenthesis. How?
def isEven(n: Int) = (n % 2) == 0
List(1, 2, 3, 4) filter isEven foreach println
I tried running this code but it didn't work. Why?
def withP(i:Int) = {
println("with p")
}
withP 1
';' expected but integer literal found.
[error] withP 1
[error] ^
[error] one error found