Speaker: Neha Sardana
Link to table of contents
<missed this part; I was late>
- Want to control children
- More declarative than access modifiers
- Can make widely accessible interface without widely extensible
- Sets stage for pattern matching.
- Pattern matching created in 1960s
- Helps with clean code, avoiding repetition/bugs
- matches target object to type pattern
- sets binding variable – special case of local variables, can be assigned, can shadow field declarations
- flow scoping – places in program where variable definitely assigned
- Limitations on switch/case are accidents of history.
- Java 17 preview allows pattern matching in case
- Java 19 – write ”when” instead of && in case
- Can assign result if all cases covered. (enums and sealed classes can be listed exhaustively
- Record patterns (deconstrution patterns). ex if (r instanceof Rectangle (Point ul, Point lr))
- Can also deconstruct arrays
I thought this topic woud be fully review, but I still learned something (“when”). It was great to see Neha’s first public in person presentation! Good job!