From: "David A. Black" Date: 2008-04-12T04:54:19+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:37 +0900), David A. Black wrote: > >>> 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. > > Ok, so your intention with your example was to show how you think > reject! should work, return same array as the destination > would be after? Not an example run of how I wish it would work. > Then we can just agree to disagree :). I don't see any problem > foo! method returning different value than the value of > destination object after the method has finished. > > Random core example: >>> moi.squeeze > => "moi" >>> moi.squeeze! > => nil >>> moi > => "moi" There's no general principle at stake; I'm just saying that if you want a method that behaves like select but performs an in-place reject, it's better to invent a name than override Enumerable#reject!. 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!