You should use if let
or guard let
.
if let name1 = names["1"] {
print(name1)
}
OR
guard let name1 = names["1"] else {
return
}
print(name1)
solved How to get the direct value associated with a key in a dictionary in Swift?
You should use if let
or guard let
.
if let name1 = names["1"] {
print(name1)
}
OR
guard let name1 = names["1"] else {
return
}
print(name1)
solved How to get the direct value associated with a key in a dictionary in Swift?