- What browsers show this problem?
- Please share an example project (if possible).
- Describes the steps to reproduce this issue.
- What does Snap! currently do?
['i']to both lists.
- What should Snap! do instead?
This is not a bug, it's the behavior of Snap! lists. Lists are mutable data structures. A list maintains its identity even when items are added, removed, or replaced.
So, when you do "Set (b) to (a)" and "a" is a list, you are not copying static a content, you are pointing to the same list element.
If you want to copy a "list content" you can use some "list reporters". For example:
Actually, it's not just about lists, it's about how variables work in general.
It'll probably be more obvious to you with this example:
If Snap! did what you suggest, then we'd end up with two copies of the sprite, which clearly doesn't make sense.
A variable is not a box where you put a unique thing, but just a name or a label you give to a value. The same value can be labelled hundreds of times, and it will always remain separate from the label.
A and B reference the same list.
See the Snap help dialog for "is identical to" (Operators) for more information.
OK, thanks everyone! That information will help a lot in future coding. Thanks!
P.S. what do I label this if it's not a bug?
Hmm. I guess it could either go to Help with Snap! or Computer Science.