If you are working with the functional programming paradigm and need to retrieve a specific expression depending on the value or type of an expression, you should consider using pattern matching. Pattern matching lets you check for a specific value or type of an expression, leveraging constructors and types, constants, and wildcards. You should use pattern matching and avoid nested if/else or custom methods to check conditions, to have a more readable and compact result.
Pattern matching can be applied to all data structures such as List and Map, and both to case native and custom classes (you just need to insert case in the class definition).
In this lab, you will understand how to work with pattern matching, and you will implement it with real-world cases.
Upon completion of this beginner level lab, you will be able to:
This lab is intended for:
To get the most out of this lab, you should have basic knowledge of Scala. To achieve this, we suggest taking the following labs:
April 20th, 2023 - Updated theia to enable autosave
Stefano studies Computer Science and is passionate about technology. He loves working with Cloud services and learning all the best practices for them. Google Cloud Platform and Amazon Web Services are the cloud providers he prefers. He is a Google Cloud Certified Associate Cloud Engineer. Node.js is the programming language he always uses to code. When he's not involved in studying or working, Stefano loves riding his motorbike and exploring new places.