failable initialiser swift simple example

By | August 8, 2016

failable initialiser swift simple example

In swift, Failable initialisers are used with structure,class and enumeration. When it is not sure that a property within class or structure or enumeration will be initialised then failable initialisers are used.

For this, we write initialiser with init? syntax and if initialisation succeeds then value is assigned or else nil value is assigned.

Example Code