[swift-evolution] Optional comparison operators

Sean Heber sean at fifthace.com
Tue Jul 12 09:40:43 CDT 2016


> On Jul 12, 2016, at 2:58 AM, Charlie Monroe via swift-evolution <swift-evolution at swift.org> wrote:
> 
> An example to keep in mind:
> 
> let dict: [String : String] = ...
> if dict["key"] == "value" { // String? == String
> 	// Do something
> }
> 
> If I understand correctly, when the proposal is accepted, you'd need to do something like:
> 
> if let value = dict["key"], value == "value" { } 
> -- OR --
> if dict["key"] == Optional("value") { }
> 
> It's not an end of the world, but makes life a bit more difficult and such usecase should be kept in mind.

It might not be the end of the world, but I’d argue that it’s terrible and I’d hate it. A lot.

l8r
Sean



More information about the swift-evolution mailing list