Skip to content

Instantly share code, notes, and snippets.

@amlcurran
Created July 28, 2016 21:18
Show Gist options
  • Save amlcurran/2a0b1c4a02f39716d7fd384694b525d8 to your computer and use it in GitHub Desktop.
Save amlcurran/2a0b1c4a02f39716d7fd384694b525d8 to your computer and use it in GitHub Desktop.
var string: String = "hello"
string = nil // fails to compile - trying to assign nil to a non-optional value
var optionalString: String? = "hello"
optionalString = nil // compiles fine, as we've declared this to be an optional string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment