Thursday, 15 August 2013

swift - Immutable Dictionary value change -



swift - Immutable Dictionary value change -

can alter pair value in allow type dictionary in swift langauage.

like :

let arr2 : anyobject[] = [1, "23", "hello"] arr2[1] = 23 arr2 // output: [1,23,"hello"] allow arr1 :dictionary<int,anyobject> = [1: "one" , 2 : 2] arr1[2] = 4 // not posible error arr1

in case of immutable array can alter value above not in case of immutable dictionary. why?

this taken swift programming language book:

for dictionaries, immutability means cannot replace value existing key in dictionary. immutable dictionary’s contents cannot changed 1 time set.

immutability has different meaning arrays, however. still not allowed perform action has potential alter size of immutable array, allowed set new value existing index in array.

swift

No comments:

Post a Comment