Skip to content

Instantly share code, notes, and snippets.

@regularberry
Last active April 28, 2018 21:53
Show Gist options
  • Save regularberry/04b615fab4d040e852c7d531746c7fa9 to your computer and use it in GitHub Desktop.
Save regularberry/04b615fab4d040e852c7d531746c7fa9 to your computer and use it in GitHub Desktop.
Not the right nil
var dict: [String: Any?] = ["first": nil, "second": 2]
if let val = dict["first"] {
print(val)
}
// Output: nil
dict["first"] = nil
if let val = dict["first"] {
print(val)
}
// No output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment