From: "David A. Black" Date: 2008-04-12T04:20:57+09:00 Subject: Re: delete_if, select and (lack of) delete_if!, self.POLS == false Hi -- On Sat, 12 Apr 2008, Saku Ytti wrote: > On (2008-04-12 04:04 +0900), Robert Dober wrote: > >> x=[*0..1] >> x.select{|n| n.even?} -> [0] >> x -> [0,1] >> x.reject!{|n| n.odd?} -> [0] >> x -> [0] > > Not sure what's going on there, but this looks correct to me: select is selecting all the even ones, and reject! is rejecting all the odd ones, and in both cases, you're seeing the results (the array with only the even ones; the array without the odd ones). In the case of reject! you're also seeing that the contents of the array have been replaced with the results of the reject operation. I think if you want a reject operation whose return value is the same as a select operation, you'll probably need to come up with a new method name :-) David -- Rails training from David A. Black and Ruby Power and Light: ADVANCING WITH RAILS April 14-17 New York City INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin See http://www.rubypal.com for details and updates!