Optional in swift – what is optional ?

By | July 16, 2016

Optional in swift- what is optional in swift ?

In swift, a variable either may contain a value or nothing (nil). Put “?” after the variable type. So, to declare such variable, following syntax is used :

Another way to handle optional values is to use the ?? operator