3 ms·
No, "guard" in Swift is special. Once you're in the "else" block, you MUST return or call a non-returning function (e.g. abort). It's specifically designed to
by iainmerrick 2y ago
No, "guard" in Swift is special. Once you're in the "else" block, you MUST return or call a non-returning function (e.g. abort).
It's specifically designed to prevent bugs where flow control accidentally resumes from an error handler.
It's the same idea as the "every 'if' must have an 'else'" guideline in the code being discussed, except with "guard" the compiler will detect violations. It's a good thing.