xcode: | 11 |
---|---|
target/platform: | iOS 13.1 |
swift: | 5 |
warning: | 'defer' statement before end of scope always executes immediately; replace with 'do' statement to silence this warning |
fix-suggest: | Replace 'defer' with 'do' |
func doSomething(value: Int?, value2: Int?) {
guard let value = value else { return }
defer {
print(value2 ?? "nil")
}
}
doSomething(value: nil, value2: 1) // result:
doSomething(value: 1, value2: nil) // result: nil