[swift-evolution] Remove Failable Initializers

Haravikk swift-evolution at haravikk.me
Thu Mar 3 14:40:07 CST 2016

> On 3 Mar 2016, at 09:20, Brent Royal-Gordon <brent at architechies.com> wrote:
> it's really nice to be able to use if-let, guard-let, or ?? to handle them instead of having to write an entire do/catch block.

What’s wrong with:

	guard let myInstance = try? ErrorThrowingType() else { return }

This has the exact same flexibility, and works just as well with the ?? operator as a failable initialiser, in fact that’s one of the main reasons why try? was added I think.

Personally I think what it boils down to for me is that these initialisers are failing, which means that an error has occurred, which means that they should use error handling. On the other side I don’t see optionals as representing errors (and they shouldn’t be used to anymore IMO), but instead the result of something that doesn’t have to return a value (but has been used correctly).

More information about the swift-evolution mailing list