3 ms·
Optional binding can refine the type. https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/#Optional-Binding https://docs.s
by paxcoder 3y ago
Optional binding can refine the type.
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/#Optional-Binding https://docs.swift.org/swift-book/documentation/the-swift-pr...
- FeepingCreature 3y agoYes, as I mentioned, it's like an `if` with multiple bindings, but I don't force intermediate variable names. That example is in the article. :P edit: Wait, it's not in the article, I rewrote it and removed that section. My apologies! Anyway, yes, it's like that.
- paxcoder 3y agoI'm not sure I understand what you mean by multiple bindings? With if-let, binding to the variable is conditional, and it only happens if all parts of the chain return an actual value. Otherwise, as soon as one returns null, a jump can be made to the alternative branch. Am I missing something?