Chapter 4. Fun with Functions, and Never Having to Close That JDBC Connection

We saw Scala functions in action in the last chapter. Passing functions to map and filter allowed us to write code that was more readable and understandable. The looping was done in the method, allowing our application code to be cleaner and easier to maintain. In this chapter, we'll explore functions in more depth and learn about how functions allow us to encapsulate business logic and separate it from the imperative flow of control statements. We'll write our own control structures, including looping and automatic JDBC connection closers that will lead to cleaner, better code.

A Function Is an Instance

In Scala, functions are instances of classes. You can do anything ...

Get Beginning Scala 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.