Skip to content
Sharp

Language Upgrades · interview question

Why is pattern matching in a switch especially valuable over a sealed hierarchy?

Multiple choiceMediumchapter-12-curatedpremiumlanguage-upgradespattern-matching
Choose one answer
Answer and explanation

Correct answer

D. Readable typed handling plus compiler-checked exhaustiveness

Why

Pattern matching in switch expressions reduces manual casts and makes each branch explicit. With sealed types, the compiler can also force you to handle every valid variant.

Test yourself on Language Upgrades

A free test with instant, explained results. No account needed.

Start free test
All Language Upgrades questions →