Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

swift modify dictionary

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])" )
 
PREVIOUS NEXT
Tagged: #swift #modify #dictionary
ADD COMMENT
Topic
Name
2+4 =