Wrapping Up

In this chapter, we explored the concepts related to function values; functions are first-class citizens in Scala. You can use code blocks to enhance the functionality of another function. You can use them to specify a predicate, a query, or a constraint to the logic being implemented in a method. You can use them to alter the control flow of a method—for example, when iterating over a collection of values. You also learned about the Execute Around Method pattern, a valuable feature that you’ll use quite frequently in Scala, both in your own code and most commonly when using the Scala library. In the next chapter, we’ll walk through another interesting Scala idiom: traits.

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