Skip to content
Sharp

Language Upgrades · interview question

How does pattern matching in switch expressions enhance type safety compared to traditional switch statements?

Multiple choiceMediumchapter-12-curatedpremiumlanguage-upgradesmigration-strategy
Choose one answer
Answer and explanation

Correct answer

B. It enables compile-time checking of exhaustive case handling.

Why

Pattern matching in switch expressions ensures that all possible cases are handled at compile-time, enhancing type safety by preventing runtime type errors.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →