Scala combines both object-oriented and functional programming paradigms. In particular, functions are a first-class language concept. They can be defined in a variety of ways, assigned to variables, passed as parameters, and stored in data structures. Scala gives a lot of flexibility with regard to how these actions can be performed.
We'll start this chapter by looking in detail at different flavors of defining a function. We'll then go on and apply the knowledge about types from the previous chapter to make our functions polymorphic and higher order. We'll study recursion, tail recursion, and trampolining as important aspects of functional programming for the JVM. Finally, we'll evaluate peculiarities related to the fact that functions in Scala are implemented in an object-oriented way.
The following topics will be covered in this...