Thursday, November 17, 2016 [Tweets] [Favorites]

Mixing Swift Initializers

Russ Bishop:

Let’s say you have a type with a failable initializer. Now you want to extend that type to support deserializing from JSON. You throw nice detailed errors if JSON parsing fails and you’d like to throw if anything goes wrong[…] There are two problems here. One is that we can’t delegate to a failable initializer. […] The second is there is no syntax to checking the result of calling the failable initializer even if we could; self is only optional in the context of a failable initializer.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment