Skip to content

Instantly share code, notes, and snippets.

@jah2488
Created October 23, 2016 00:31
Show Gist options
  • Save jah2488/011db9a57eb42dcf18325e9459d2ae94 to your computer and use it in GitHub Desktop.
Save jah2488/011db9a57eb42dcf18325e9459d2ae94 to your computer and use it in GitHub Desktop.
# Structured and Nested
obj = {
container_a = {
name: "Foo",
contents: [item_a, item_b, item_e]
}
container_b = {
name: "Bar",
contents: [item_c, item_d, item_z]
}
}
## VS
# Unstructured and Flat
obj = {
contents: [
{ val: item_a, location: 'container_a' },
{ val: item_b, location: 'container_a' },
{ val: item_c, location: 'container_b' },
{ val: item_d, location: 'container_b' },
{ val: item_e, location: 'container_a' },
{ val: item_z, location: 'container_b' },
]
}
move_item(obj, item_e, 'container_b')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment