Deep Dive into Functions

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 ...

Get Learn Scala Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.