On Sun, Sep 25, 2016 at 9:22 PM, Brent Royal-Gordon <[email protected]> wrote: > > Not true; it's an attempt to access the `numberOfRooms` property on > `Optional<Residence>`. That property doesn't exist, but it could be added > using an extension. > > (And `Optional` does have several members—most notably `map`, `flatMap`, and > `unsafelyUnwrapped`.)
Oh Haskell, what have you wrought ;-) Good point. Pretty sure my proposal translates into making flatMap the default dispatch behavior for Optionals. I think map might well be a YAGNI. I've tried a number of examples, and in every case where map was used flatMap worked ... and is probably what is intended anyway. map can return double optionals and error (and if you want the error you can explicitly unwrap). Of course there has to be way around the default flatMap behavior, probably the simplest is to just make an exception for any public member of Optional. (This sort of thing is not uncommon in Ruby actually, when method_missing is used). I'd much rather have to be aware of a few uncommon corner cases calling methods on Optional than to have to explicitly cater to every Optional throughout my code. -- People with courage and character always seem sinister to the rest. --Hermann Hesse Trans <[email protected]> 7r4n5.com http://7r4n5.com _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
