On Tue, 3 Dec 2002, Mauricio [iso-8859-1] Fern?ndez wrote:

> On Tue, Dec 03, 2002 at 10:58:15PM +0900, Roman Rytov wrote:
> >
> > Anotehr question is about COLLECT;
> >
> > myarray.collect {|x| x + ", "}
> >
> > I wanna execute only over specific emelents (let's say only odd ones or
> > all but last).
>
> myarray.select{ |x| x % 2 == 1 }.collect{ |x| x + ", " }  #.join here ?

That's going to work only on numerical elements... which the
collect clause then won't work on.  I think Roman meant odd-numbered
indices (?).  (Which doesn't explain why I used even-numbered
indices in my example -- oh well :-)


David Black