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?' 
  1. what int?? mean?
  2. 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

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -