Let my explain my bug with the help of the photo:
So I have 2 lists and 2 local variables. Let’s do this in steps…
- I initialize the second list [lista_mod] to my first list [lista];
- I make operations on the second list [lista_mod];
- The first list [lista] is untouched;
- The second list is OK, after appending everything goes as I want.
- BOOM, my first list [lista] is changed excatly to the point as the second list.
- At the end nr 1 list = nr 2 list. It looks like these two list share the same memory place.
It makes my work harder. The picture is a small fragment of my JSON parser.
I got this bug earlier. I had to add splitted list to variable instead of just the list because it was writing different list to it.
But still, I need an explanation. Why this happens?