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)
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground