Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Members of a list become disassociated when you mutate them #13

Open
nickretallack opened this issue Jun 9, 2012 · 1 comment
Open

Comments

@nickretallack
Copy link

Say you have a protocol buffer that contains a repeated element which in turn contains more repeated elements. If you mutate one of the repeated elements at the root, you're fine. However, if you mutate a repeated element that is a child of another repeated element, it becomes a different object from the one that's in its parent's list.

This demonstrates how the same object gets dissociated

nested_item = Top.items[0]
nested_item.items += (item,)
nested_item.items.length != Top.items[0].items.length

This quickly demonstrates the anomaly and how it eats data

length_before = Top.items[0].items.length
Top.items[0].items += (item,)
length_after = Top.items[0].items.length
length_before == length_after
@nickretallack
Copy link
Author

I can work around the issue by recursively placing the new element into its parents' lists. This is a little awkward, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant