본문 바로가기

Programming/Swift

When to use guard let rather than if let

Swift gives us an alternative to if let called guard let, which also unwraps optionals if they contain a value, but works slightly differently: guard let is designed to exit the current function, loop, or condition if the check fails, so any values you unwrap using it will stay around after the check.

 

 

When to use guard let rather than if let - a free Understanding Swift tutorial

Was this page useful? Let us know! 1 2 3 4 5

www.hackingwithswift.com

 

'Programming > Swift' 카테고리의 다른 글

Collection Types in Swift  (0) 2020.11.27
Can an array contain different data types?  (0) 2020.11.27
Nil coalescing  (0) 2020.11.25
What is Cyclomatic complexity?  (0) 2020.11.25
Closures  (0) 2020.11.11