On 10/23/07, David A. Black <dblack / rubypal.com> wrote:
> Hi --
>
> On Tue, 23 Oct 2007, Jes Gabriel y Gal wrote:
>
> > On 10/23/07, richard.j.dale / gmail.com <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.

Not only that, but enqueue and dequeue return different objects.
Enqueue returns an array, and dequeue returns the object that was
shifted from the stack.

Todd