Functions as objects

  • The function type A => B is just an abbreviation for the class scala. Function1[A, B], which is defined as follows. 

  • An anonymous function such as 

is expanded to: 

  • A function call, such as f(a), where f is a value of some class type, is expanded to f.apply(a) 

would be 

  • A method such as 

is not itself a function value. 

But if f is used in a place where a Function type is expected, it is converted automatically to the function value


You May Also Like

About the Author: Phuong Ta Thi Thao

Leave a Reply

Notify of