February 2018
Intermediate to advanced
552 pages
13h 46m
English
In general, a function is an operation that takes some inputs, processes them, and returns results. It is the same for the Scala language too. Take a look at the following diagram:

Sometimes, a function is also known as an operation, routine, procedure, or method, depending on the context in which we use it.
In Scala, we can define a function using def, as shown here:
def add (a: Int, b: Int) : Int = a + b
Here, the add function has two inputs, a and b, of the same type, Int, and returns Int as a result.
Scala supports some syntactic sugar to write the same function in different ways:
def add (a: Int, b: Int) : Int = { a + ...