Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



#anonymous-functions #functions #scala

The following expression creates a successor function for integers:

var inc = (x:Int) => x+1

Variable inc is now a function that can be used the usual way:

var x = inc(7)-1
If you want to change selection, open document below and click on "Move attachment"

Scala Anonymous Functions
ts called function values. Scala supports first-class functions, which means you can express functions in function literal syntax, i.e., (x: Int) => x + 1, and that functions can be represented by objects, which are called function values. <span>The following expression creates a successor function for integers: var inc = (x:Int) => x+1 Variable inc is now a function that can be used the usual way: var x = inc(7)-1 It is also possible to define functions with multiple parameters as follows: var mul = (x: Int, y: Int) => x*y Variable mul is now a function that can be used the usual way: println(


Summary

statusnot read reprioritisations
last reprioritisation on suggested re-reading day
started reading on finished reading on

Details



Discussion

Do you want to join discussion? Click here to log in or create user.