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.

The lesson behind it →
More on Language