Pattern Matching

Pattern matching provides a powerful tool for declaring business logic in a concise and maintainable way. Scala blends traditional functional programming pattern matching with object-oriented concepts to provide a very powerful mechanism for writing programs. In this chapter, you’re going to explore...

Full description

Saved in:
Bibliographic Details
Published inBeginning Scala 3 pp. 111 - 134
Main Authors Layka, Vishal, Pollak, David, Sacco, Andres
Format Book Chapter
LanguageEnglish
Published United States Apress L. P 2022
Apress
Online AccessGet full text

Cover

Loading…
More Information
Summary:Pattern matching provides a powerful tool for declaring business logic in a concise and maintainable way. Scala blends traditional functional programming pattern matching with object-oriented concepts to provide a very powerful mechanism for writing programs. In this chapter, you’re going to explore the basics of pattern matching. Then you’re going to see how Scala’s case classes bridge object-oriented data encapsulation and function decomposition. Next, you’ll see how Scala’s pattern-matching constructs become functions that can be passed around and composed. Let's look at a simple example first.
ISBN:9781484274217
1484274210
DOI:10.1007/978-1-4842-7422-4_5