Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x[y][][z]=10&x[y][][w]=a&x[y][][z]=20&x[y][][w]=c
- into:
- {'x' => {'y' => [{'z' => '10', 'w' => 'a'}, {'z' => '20', 'w' => 'b'}]}}
- push x : x
- push y : x y
- push array : x y []
- push z : x y [] z
- assign top : x y [] { z => 10 }
- shift : [{z => 10}] then {y => [{z => 10}]} then {x => {y => [{z => 10}]}}
- new top is : {x => {y => [{z => 10}]}}
- * now each push operation takes the stack top, if it's found in that hash then the value is
- pushed on instead of the token
- push x : { y => [...]}
- push y : [{z => 10}]
- push array : [{z => 10}] []
- push w : [{z => 10}] [] w
- assign top : [{z => 10}] [] { w => 'a' }
- shift : [{w => 'a'}] then [{z => 10}] + [{w => 'a'}] == [{z => 10},{w => 'a'}]
- whole thing is now {x => {y => [{z => 10}, {w => 'a'}]}}
- Basic rule would be that push tries to find the var in the top Hash (if there is one).
- If not top hash then it pushes the new var on.
- Shift adds things to arrays until there are no more.
- Shift makes new hashes and assigns them to vars with right side as value.
Add Comment
Please, Sign In to add comment