Failable Initializer in Swift

Gabriel Theodoropoulos
3 min readMay 13, 2021

As developers, we use initializers all the time to create instances of various types. We also create our own initializers when implementing custom classes or structs. But should initializers always return an instantiated object of the type they are implemented into?

It makes sense sometimes not to return an object if the initialization of one or more properties that play crucial role in the type does not…

--

--

Gabriel Theodoropoulos

An iOS & macOS app maker writing code in Swift. Author of countless programming tutorials. Content creator. https://serialcoder.dev