Wrapping Up

In this chapter, you saw one of the most powerful features of Scala. Right off the shelf, you can match simple literals, types, tuples, lists, and so on. If you want a bit more control on the matching, you can use the case class or the all-too-charming extractors. You also saw how regular expressions manifest as extractors. If you want to match simple literals, the match is quite adequate. If you want to match arbitrary patterns, Scala extractors are your friend. You’ll see pattern matching shine in concurrent programming later in this book.

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.