February 2018
Intermediate to advanced
552 pages
13h 46m
English
In Scala, Higher-Order Functions (HOF) are functions that should have one or more of the following things:
Let us explore a HOF which takes a function as a parameter, using Scala REPL function as a function parameter:
scala> val addOne = (x: Int) => x + 1 addOne: Int => Int = <function1> scala> def hof(f: Int => Int) = f hof: (f: Int => Int)Int => Int scala> val result = hof(addOne) result: Int => Int = <function1> scala> result(10) res14: Int = 11
Here, we are passing the addOne() function to the hof() function as a parameter.
We can observe these kind of functions a lot in Scala, Akka Toolkit, and Play Framework source ...
Read now
Unlock full access