Before we talk about optionals as a concept, let's look at some code in Swift that throws an error but would compile without issue in Objective-C:
var jobTitle:String = "Thought Leader" jobTitle = nil // Compile error
Objects that are declared as non-optionals can never be set to nil.
If you're an experienced programmer looking at Swift for the first time, this compilation error could come as a pretty big surprise. When you consider this fact, you come to the realization that a whole class of common programming errors simply cannot be made using Swift. For example, if you were to append two strings together in Objective-C and one of them is
nil, the app would crash at runtime. This is not possible using Swift and it is exciting news. ...