Scala Language Functions

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

Scala has first-class functions.

Difference between functions and methods:

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.

  • Functions are compiled to a class extending a trait (such as 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.
  • A method may be converted to a function, but a function cannot be converted to a method.
  • Methods can have type parameterization, whereas functions do not.
  • Methods can have parameter default values, whereas functions can not.


Got any Scala Language Question?