Swift Optional
Some people found it very confusing initially but when you will understand then it is simple. As we know optional tells itself about it. It's two cases. The first case when a value can be present for a type, then we need to unwrap if need to use it. Second case when a value can not be present for a type. We use '?' to mark a value as optional. class Student { var name: String ? // name becomes optional } When you declare the name string as optional by marking ' ? ' then it's valued automatically is set to nil. NOTE: Swift 'nil' is not same as objective c 'nil'. In Objective-C, it is a pointer to an object which does not exist whereas in swift it's just an absence of a value for a type. let person = Student() print( person .name) When you access the name it will print a nil . As there is no value assigned to name. Once we will provide a value to name, let say, "Swift". Then it looks like....