Myth: methods and functions are the same thing.
In fact, a function is a value (an instance of one of the FunctionN
classes), while a method is not. Jim McBeath explains the differences in greater detail. The most important practical distinctions are:
- Only methods can have type parameters
- Only methods can take implicit arguments
- Only methods can have named and default parameters
- When referring to a method, an underscore is often necessary to distinguish method invocation from partial function application (e.g.
str.length
evaluates to a number, while str.length _
evaluates to a zero-argument function).