Maybe I'm very confused idk yet. I thought i understood the basic concept but when playing around in xcode I'm not getting what I thought I should be Take the following code
var title: String? = "hello world"
println("\(title)")
I thought that this would give me an error because I thought that title should have to be unwrapped since I;m accessing it, but it seems to compile just fine. Can someone shed some light on this.
All an optional is is that if it is nil, the app won't crash. If you put the elimination mark, and did not assign a value, it would crash.
In an if statement, you can check if the variable is nil: