Scala has first-class functions.
A function is not a method in Scala: functions are a value, and may be assigned as such. Methods (created using def
), on the other hand, must belong to a class, trait or object.
Function1
) at compile-time, and are instantiated to a value at runtime. Methods, on the other hand, are members of their class, trait or object, and do not exist outside of that.