if let
and guard let
?Suggested approach: Both check and unwrap optionals, but guard
forces an early return if its check fails – your code will literally not compile unless you exit the scope. Furthermore, any variables that guard
unwraps stay in scope after the guard
block, whereas with if let
the variables are available only inside the scope.
Estimated difficulty: Easy
See the full list of iOS interview questions
Link copied to your pasteboard.