10 ms·
a = [1,2,3] b = a b += [1] => a == [1,2,3,1] a and b point to the same piece of memory even if you don't have to explicitly deal with pointers, you
by cgag 12y ago
a = [1,2,3]
b = a
b += [1]
=> a == [1,2,3,1]
a and b point to the same piece of memory even if you don't have to explicitly deal with pointers, you need to reason about them
- icebraining 12y agoYou just have to explain that "b = a" means that you're adding a new name to the thing/object named "a". Whether it's in the same memory location or not is an irrelevant implementation detail.