Martin DeMello
5/6/2005 11:54:00 AM
David A. Black <dblack@wobblini.net> wrote:
> On Fri, 6 May 2005, Martin DeMello wrote:
>
> > The recent mention of String#squeeze made me wonder if it would not be a
> > good idea to add a #squeeze method to Array (or possibly even to
> > Enumerable) as well. Certainly I've needed it at least as often as I've
> > needed #uniq
>
> How close is this to what you might want, at least for Array?
>
> irb(main):001:0> a = [1,2,3,4,1,2]
> => [1, 2, 3, 4, 1, 2]
> irb(main):002:0> a |= [1,2]
> => [1, 2, 3, 4]
Nope, that's not what I meant - I wanted to compress a run of elements
into a single element, pretty much like unix's uniq does. (Logan posted
an implementation already).
martin