Introduction to Optionals (Part 2)
The second part of optionals! I get Optional Binding so we'll see what we have next... Downsides to using If Let Optional binding is used with the if let. The example Pasan gives highlights a couple of flaws - what if we don't have the data? Well, we would have to use else and nil. struct Friend { let name: String let age: String let address: String ? } func new(friendDictionary: [ String : String ]) -> Friend ? { let name = friendDictionary[ "name" ] if name == nil { return nil } let address = friendDictionary[ "address" ] } The issue here is we would have to return the values using ! which is not recommended. The main point Pasan makes is that optional binding is laborious but it was necessary...