Skip to content

Instantly share code, notes, and snippets.

@alexkent
Created August 1, 2014 14:48
Show Gist options
  • Save alexkent/4c71578ad2e0e4e58923 to your computer and use it in GitHub Desktop.
Save alexkent/4c71578ad2e0e4e58923 to your computer and use it in GitHub Desktop.
var iExist:String?
var s:[String:Any] = [String:Any]()
s["thing"] = 2
if let x = s["thing"] {
iExist = x
}
// explicit cast x
if let x:String = s["thing"] {
iExist = x
}
// which leaves me with
if let x:String = s["thing"] as? String {
iExist = x
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment