Sorry for very general topic name, I couldn't find better one.
I have a problem/question concerning lists. I have a code similar to this:
set listA to create new list
set listB to create new list
set listB to split [2,2,0,-1] using separator [,]
print listA
replace item #2 with -1 in listB
add listB to listA
print listA
replace item #2 with 1 in listB
print listA
empty listB
print listA
Now, I was pretty sure that this code should print this result:
2,2,0,-1
2,2,0,-1,2,2,-1,-1
2,2,0,-1,2,2,-1,-1,2,2,1,-1
2,2,0,-1,2,2,-1,-1,2,2,1,-1
However, I get this:
2,2,0,-1
2,2,-1,-1,2,2,-1,-1
2,2,1,-1,2,2,1,-1,2,2,1,-1
,,
Can anyone explain to me why does it happen? Why are items in listA affected by changes to listB that were made after listB was put in listA. I thought that when you put an item in a list, you don't really put the attribute itself there, but only the value of that attribute. So when you change the attribute later, it won't change the value inside the list. And I have pages of code that work like this. But not in this case.
Edit: Just after finishing this post I checked something. Using "set listB" kind of fix this. I mean this block will change listB, but will not change any item in listA, while "replace item x in listB" and "empty listB" will change items already saved in listA. I really don't get it.