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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -