Scala language has support for “Function” types which you can use to define your own functions while solving your business problems.
These “Function” types are generic. That is they take in type parameters.
Functions have to be generic. The reason is that as a programmer you would be working with your own types, and if you do not have a way to include these types into your function definitions, then you are severely limited in being able to use functions.
In Scala, FunctionN is a mapping from N number of parameters to one result value where N ranges from 1 to 22. Now, these N parameters can be of any type — and you are the one who defines what type each of these parameters should be based on your business need. And you also define the type of the return value.
So any FunctionN would have N + 1 type parameters involved in it’s definition. The first N types would define the parameter types and the last type specifies the type of the return value.
If you are wondering what if there are no return values from the function, how would that be indicated in the (N+1)th type indicating the type of the return value, the answer is pretty elementary — use “Unit” as the type. “Unit” in scala corresponds to “void” in Java.