Scala has first-class functions. Not only can you define functions and call
them, but you can write down functions as unnamed literals and then pass
them around as values.

And as such we can do the following:

So we have first class functions, and what we did is good already, but what else can we do?

Well in scala functions inherit from Function1...22 traits depending on the number of arguments they have. The Function1 trait provides some extra functionality we can use to get some more juice out of scala functions.

So using function composition you can create more interesting logic out of simple functions. This makes it easier to test, debug and even prove you functions to be correct(provided you don't have side effects and simply return the result).


Programming in Scala, 2nd Edition