Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pattern Matching

Exercise 1: Basic Case Class and Pattern Matching

Task: Define a case class for a Person with two fields: name (String) and age (Int). Write a function that accepts a Person and returns a greeting message that varies based on the person's age.

Exercise 2: Using Case Classes in Collections