3 ms·
For updates and initialization, I wonder the same thing. In a discussion about adding chaining syntax to CoffeeScript, one of the contributors wondered about li
by raganwald 15y ago
For updates and initialization, I wonder the same thing. In a discussion about adding chaining syntax to CoffeeScript, one of the contributors wondered about libraries that handle traversing a structure for you:
foo.update
color: ‘blue’
suffix: ‘singular'
barCollection:
color: ‘green’
suffix: ‘plural’
This is probably far superior for fairly static tree navigation.
- politician 15y agoAren't JavaScript objects supposed to be unordered sets? Why is that example equivalent to `foo.color('blue').suffix('singular').barCollection.color('green').suffix('plural')`? (Is it?)
- raganwald 15y agoThey are unordered. For certain types of updates, the order is immaterial and a hash of attributes could be applied. On the other hand, if you are mutating a tree as you go along, the order is important and you want to call methods and/or functions to traverse and apply side-effects.