Here are five things you should know about pattern matching in Java that are more general than type patterns with `instanceof`: 1. goals 2. terminology 3. scoping 4. reassignments 5. combinations This thread is the short form - long form: nipafx.dev/java-pattern-m… 1/10
NB: I use type patterns (in #Java16 - we know them), destructuring patters (in the works - we can make guesses), and regex patterns (I made them up) as examples - don't expect the latter two to ever work, at least not as presented here. 2/10
1. Goals A common programming pattern is: * take a variable * test whether it has a desired property * if it does, extract some values In Java, these test-and-extract patterns are mostly implemented with simple `if`s and method calls. 3/10