Modify the key-value pair

var change = [
  "Quarter": 0.29,
  "Dime": 0.15,
  "Nickel": 0.05
]
// Change the value using subscript syntax
change["Quarter"] = .25
// Change the value using .updateValue()
change. updateValue(.10, forKey: "Dime")

To change the value of a key-value pair, use the .updateValue() method or the subscript syntax by appending brackets [ ] with the existing keys within to the name of the dictionary, then adding the assignment operator (= ) followed by the modified value

Comments