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...
Saved in:
Published in | Beginning Scala 3 pp. 111 - 134 |
---|---|
Main Authors | , , |
Format | Book Chapter |
Language | English |
Published |
United States
Apress L. P
2022
Apress |
Online Access | Get full text |
Cover
Loading…
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 |