Set dictionary element for key

 Problem

I have a Dictionary and want to set a new value to one of its elements, by key.



 Recipe


// Initialize the Dictionary
var dict = ["name": "John", "surname": "Doe"]
 
// Set the element with key: 'name' to 'Jane'

dict["name"] = "Jane"

print(dict)
				


 Playground

Find answers here

Hi there! Ask Us a Question We are ready to help