Overview - Switch must be exhaustive
What is it?
In Swift, a switch statement must cover every possible value of the variable it checks. This means you cannot leave out any case without handling it explicitly or using a default case. This rule helps prevent unexpected behavior by making sure all possibilities are considered.
Why it matters
This rule exists to make programs safer and more predictable. Without exhaustive switches, some values might be ignored, causing bugs that are hard to find. Imagine a traffic light controller that forgets to handle the green light; it could cause accidents. Swift forces you to think about every option so your code is more reliable.
Where it fits
Before learning this, you should understand basic Swift syntax and how switch statements work. After this, you can learn about pattern matching, enums with associated values, and advanced control flow in Swift.