swift - Why can't I update a Dictionary Key:Value pair that has nil as the value? -
in following code:
var dict1: [string:int?] = ["blue" : 1, "red" : nil] let a: int? = dict1.updatevalue(2, forkey: "red")
i error:
"cannot convert value of type 'int??' specified type 'int?'
- what int?? mean?
- what's proper way update dictionaries if target pair has nil value?
the first question mark because dictionary's values int?. second question mark because call updatevalue returns optional wrapping 1 of dictionary's values. int??
Comments
Post a Comment