On 10/23/07, David A. Black <dblack / rubypal.com> wrote:
> On Tue, 23 Oct 2007, Jes=FAs Gabriel y Gal=E1n wrote:
> > 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.

Fair enough, although the idea was to use such an object using just
queue semantics, so everybody knows what enqueue/dequeue do. Maybe
aliasing them in Array doesn't make sense: what about having those
alias in a class Queue < Array or in the instance of the array you
plan to use just as a queue?

queue =3D []
class << queue
   alias :enqueue :push
   alias :dequeue :shift
end


Jesus.