Java Patterns and Switch
Similar to Record Patterns, the Pattern Matching for Switch includes:
- a type check in the form of case checks;
- creation and assignment of variable; and
- typecasting of the variable.
For example:
Your Turn
Let's use the Java Playground to test out these patterns.
Resources
- Veterinarian Office - Pattern Matching Mini-Lab
- For more on Pattern Matching and what's to come, check out this video by Nicolai Parlog.