Question 6
Back to Exercise
When can a switch expression over an enum omit default?
- A Never
- B When it has a case for every enum constant (it is exhaustive) Correct
- C Always
- D Only for String switches
Correct Answer: Option B
The same applies to a sealed type whose permitted subtypes are all covered.
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!