From: "David A. Black" Date: 2008-04-12T04:37:04+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:20 +0900), David A. Black wrote: > >> 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. > > Are you talking about your example or my example? They did different thing, > I'm not sure why your did what it did above. > >> 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 :-) > > The reject! in my example does mutable reject, as one would expect. > But it also returns the non-rejected entries (that is, those entries that > select for same block would return). Having reject return the non-rejected entries is what I was referring to. That's not how reject (with or without !) works, so if you want a method that does that you'd want to find a different name for it. 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!