Daily iOS
Swift

Force unwrap rule

Your team's code review rules include "no force unwrapping (!)." Why have a rule like that?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

A force unwrap crashes at runtime the instant the value is nil, and it bypasses the nil check the compiler asks for, so it's banned. Instead you bind with if let or guard let, give a default with ??, or step over with ?., so nil is handled as one branch of normal flow.

Share a question