From: "David A. Black" Date: 2007-10-23T23:06:00+09:00 Subject: Re: pop/push, shift/unshift --1926193751-840406803-1193148362=:30404 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-840406803-1193148362=:30404" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-840406803-1193148362=:30404 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Tue, 23 Oct 2007, Jes=FAs Gabriel y Gal=E1n wrote: > On 10/23/07, richard.j.dale@gmail.com wrote: > >> Maybe 'enque' and 'deque' could be used as names for methods to put >> items on the front of a Queue and remove items from the back somewhere >> in Ruby - then you wouldn't need push/pop and shift/unshift depending >> on which end of the queue you were operating on. > > I like this: > > class Array > alias :enqueue :push > alias :dequeue :shift > end > > Then you get Queue semantics and the start of the queue is the first > element in the Array :-). (you could do enqueue --> unshift, dequeue > --> pop if you rather have the first element of the queue the last in > the array). No thanks. #shift/#unshift are fine, and certainly I don't want to have to figure out what people have aliased enqueue and dequeue to before I can understand their code. David --=20 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! --1926193751-840406803-1193148362=:30404-- --1926193751-840406803-1193148362=:30404--