Languagemedium3-5 years
What changed in switch, and why should a sealed switch have no default?
Arrow cases (no fall-through), switch as an expression with yield, exhaustiveness checking, and pattern matching with record deconstruction and guards. Over an enum or a sealed type, omitting default makes the compiler fail when a new case appears — which is the point.
PreviousWhat is the difference between int and Integer? Where does autoboxing bite?Next How are overloading and overriding resolved differently?