Swift Change Value Of Dictionary

[Solved] Swift Change Value Of Dictionary | Swift - Code Explorer | yomemimo.com
Question : Swift Change Value of Dictionary

Answered by : samer-saeid

var studentID = [111: "Eric", 112: "Kyle", 113: "Butters"]
print("Initial Dictionary: ", studentID)
studentID[112] = "Stan"
print("Updated Dictionary: ", studentID)

Source : | Last Update : Thu, 23 Jun 22

Question : swift modify dictionary

Answered by : tawhid-bin-omar

var someDict:[Int:String] = [1:"One", 2:"Two", 3:"Three"]
var oldVal = someDict.updateValue("New value of one", forKey: 1)
var someVar = someDict[1]
print( "Old value of key = 1 is \(oldVal)" )
print( "Value of key = 1 is \(someVar)" )
print( "Value of key = 2 is \(someDict[2])" )
print( "Value of key = 3 is \(someDict[3])" )

Source : | Last Update : Fri, 18 Mar 22

Answers related to swift change value of dictionary

Code Explorer Popular Question For Swift