O'Reilly logo

Scala Functional Programming Patterns by Atul S. Khot

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

The underscore – Scala's Swiss army knife

The underscore is an amazing thing that comes in handy in many situations. Here are some uses of the underscore that we need to know about. We will deal with other exotic uses as we come across them.

A Scala method is a part of a class. A method has a name and a signature. You can also put annotations in a method. We have already seen the @tailrec annotation in Chapter 3, Recursion and Chasing Your Own Tail.

On the other hand, a function in Scala is an object or, moreover, an object implementing one of the function traits. A one parameter function implements Function1, a two parameter function implements Function 2 and so on.

When we create a variable whose value is a function object and when we call this ...

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