I created a NSMutableArray in swift using let and
when I add addObject in the mutableArray then it will add it even though I
used the let to assign a constant. Can anyone explain how let works in swift? If it doesn't allow you to add value in later then how is the following
code working?
let arr : NSMutableArray = [1,2,3,4,5]
arr.addObject(6)
println(arr)
letdoes not mean the array is not mutable. It means the variablearrcannot be set to any other object.varorlet, mutable is mutable. The difference isletcannot be reassigned to another object. But adding an object is not reassigning. That's why the code given works.