Skip to content

Instantly share code, notes, and snippets.

@an0
Last active February 28, 2017 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save an0/50610ded2d02ba400278 to your computer and use it in GitHub Desktop.
Save an0/50610ded2d02ba400278 to your computer and use it in GitHub Desktop.
// Discussion: https://twitter.com/an0/status/644176341986856960
["a": "a"] as? [String: Any] // warning: conditional cast from '[String : Any]' to '[String : Any]' always succeeds
let a: Any = ["a": "a"]
let b = a as? [String: String]
let c = a as? [String: AnyObject]
let d = a as? [String: Any]
if let b = b {
let e = b as? [String: Any] // error: '[String : String]' is not convertible to '[String : Any]'
}
if let c = c {
let f = c as? [String: Any] // error: '[String : AnyObject]' is not convertible to '[String : Any]'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment