kristopolous / TickTick

JSON in your Bash scripts
http://9ol.es/TheEmperorsNewClothes.html
Other
579 stars 55 forks source link

shift and pop work in some weird fun way #33

Open kristopolous opened 10 years ago

kristopolous commented 10 years ago

I'm not sure whether this is a useful thing or whether it should be changed, but as an artifact of how it was created, shift will "move the tree along". That is to say that

[ { a: [1, 2] }, { b: [3, 4] } }

shifted will result in

[ { a: [2, 3] }, { b: [4] } ]

As opposed to the more conventional

[ { b: [3, 4] } ]

We can call this a bug if we want - but only because it doesn't do what conventional languages do. We can also just reclassify this as a feature, legitimately, some kind of "esoteric full-depth shift".

But if this was to be the case, then it should at least get christened a new name.

I made a gist of the test code that illustrates this: https://gist.github.com/kristopolous/a48600348341007af943