[swift-evolution] Remove Failable Initializers

Brent Royal-Gordon brent at architechies.com
Wed Mar 9 14:23:02 CST 2016


> I would love to take a page out of Ruby's book which has ! for things that are dangerous and ? for boolean expression. Instead for Swift we could have ? for optional returns and ! for forced unwrapped.
> 
> So we would have:
> 
> Object()
> OptionalObject?()
> 
> value
> optionalValue?
> forcedUnwrappedValue!
> 
> function()
> optionalFunction?()
> forcedUnwrappedValue!()
> 
> optionalProtocolMethod?()
> forcedProtocolMethod!()

You do understand that `?` at the end of a symbol already means something else, don't you? That's how optional chaining works.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list