Question 18
Back to Exercise
Why can a switch over a sealed interface omit default?
- A default is always optional
- B The compiler knows all permitted subtypes and checks that each is handled Correct
- C Sealed types cannot be null
- D Only records are allowed
Correct Answer: Option B
Adding a new subtype then produces compile errors where it is not handled.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!