Skip to content
Sharp

Language Upgrades · interview question

How would you explain a potential pitfall of using pattern matching with a switch expression when dealing with legacy types in an interview?

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

Correct answer

C. Incorrect handling due to missing exhaustive checks.

Why

When dealing with legacy types, missing exhaustive checks in a pattern matching switch expression can lead to runtime errors if all possible types are not explicitly handled.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →