Method name means invocation while function name means the function itself

Because methods can't be the final value of an expression, so if you write a method name and if it doesn't take any argument (no argument list or an empty argument list), the expression is meant to call that method to get the final value. Because functions can be the final value, if you just write the function name, no invocation will occur and you will get the function as the final value. To force the invocation, you must write ():

This is because when a function is expected but a method is provided, it will be automatically converted into a function. This is called the ETA expansion. This makes it a lot easier to use the methods we created. You can verify this behavior with the tests below:

//not expecting a function, so the method won't be converted.scala> val v3 = m3<console>:5: error: missing arguments for method m3 in object $iw;follow this method with `_' if you want to treat it as a partially applied function val v3 = m3 ^

With this automatic conversion, we can write concise code like:

//10.< is interpreted as obj.method so is still a method. Then it is converted to a function.scala> myList.filter(10.<)res31: List[Int] = List(56, 72)

Because in Scala operators are interpreted as methods:

prefix: op obj is interpreted as obj.op.

infix: obj1 op obj2 is interpreted as obj1.op(obj2).

postfix: obj op is interpreted as obj.op.

You could write 10< instead of 10.

scala> myList.filter(10<) res33: List[Int] = List(56, 72)

How to force a method to become a function?

When a function is not expected, you can still explicitly convert a method into a function (ETA expansion) by writing an underscore after the method name: