From: Randy Kramer Date: 2007-10-23T20:39:52+09:00 Subject: Re: pop/push, shift/unshift On Tuesday 23 October 2007 12:46 am, Konrad Meyer wrote: > Push and pop have been around as instructions since the days of asm. The > common "visualisation" is to imagine a dinner-plate-stack-holder at a buffet. > You push plates down into the spring-loaded stack to add more. When you want > to remove a plate, you pop it out of the top of the stack. That's probably > not the best description of the idea, but you can always google for push/pop. I always liked that visualization. The problem for me (and I'm not the OP) is that in Ruby you have to lift all the plates off, put the new plate on the bottom, and then put all the plates back. (Likewise when you want to "pop" that plate.) ;-) (Because Ruby uses push and pop on the end of the array instead of the beginning.) It's not a major problem, but it did surprise me the first time I ran into it, and I suppose this approach is a little easier to implement. (And, if push and pop were built on a separate "stack" data structure (instead of being built on the array structure (with various other paradigms, like being able to access any item in the array via the index), this point would not come up.) Randy Kramer