O'Reilly logo

Beginning Scala by David Pollak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required