Hi -- On Tue, 23 Oct 2007, Randy Kramer wrote: > On Tuesday 23 October 2007 07:44 am, Robert Klemme wrote: >> 2007/10/23, Randy Kramer <rhkramer / gmail.com>: >>> 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.) >> >> I'm not sure what exactly you mean. #push and #pop just work as one >> would expect from a LIFO. > > Well, it was partly an attempt at humor, and partly the result of some strange > coding I did recently in a program to convert files in what I call askRhk03 > format to askRhk04 format. > > In doing that, I had the need (or it seemed convenient) to both push and pop > things on to the array, but then also access all the items in the array in > order. (I.e., using something like array.each { } > > But, the first time I attempted it, without noticing that a push occurred on > the end of the array instead of the beginning, I got the wrong results. (No > big deal, I just used array.reverse first.) Have a look at #shift and #unshift. David -- Upcoming training by David A. Black/Ruby Power and Light, LLC: * Advancing With Rails, Edison, NJ, November 6-9 * Advancing With Rails, Berlin, Germany, November 19-22 * Intro to Rails, London, UK, December 3-6 (by Skills Matter) See http://www.rubypal.com for details!