Tutorial by Examples

The Scala compiler will automatically convert methods into function values for the purpose of passing them into higher-order functions. object MyObject { def mapMethod(input: Int): String = { int.toString } } Seq(1, 2, 3).map(MyObject.mapMethod) // Seq("1", "2", &...
A higher-order function, as opposed to a first-order function, can have one of three forms: One or more of its parameters is a function, and it returns some value. It returns a function, but none of its parameters is a function. Both of the above: One or more of its parameters is a fu...
Scala supports lazy evaluation for function arguments using notation: def func(arg: => String). Such function argument might take regular String object or a higher order function with String return type. In second case, function argument would be evaluated on value access. Please see the example...

Page 1 of 1