From: "David A. Black" Date: 2005-10-08T11:00:50+09:00 Subject: Re: select! not present but reject! is Hi -- On Sat, 8 Oct 2005, Gavin Sinclair wrote: > David A. Black wrote: >> On Sat, 8 Oct 2005, Jacob Fugal wrote: >> >>> On 10/7/05, Mark Hubbart wrote: >>> >>>> Also, I'm not really advocating any action here. I'm just suggesting >>>> that it would be a little weird for "select!" to be the exact opposite >>>> of "reject!", since the Ruby definitions wouldn't stand up to the >>>> English ones. >>> >>> I'll concede that, but IMNSHO consistency between the non-bang and >>> bang versions seems more important. >> >> The most important thing, though, is that every method name be >> appropriate. If select! ("dangerous select") is the best way to >> communicate the "delete unless..." process, then it's right. If not, >> then not. It's reasonable to expect that a/b == a!/b! -- but the >> existence of a, b, and a! doesn't mean that b! is a good method name >> for the inverse of a!. > > Perhaps not, but in this case, inconsistency would be unforgivable. As I've said repeatedly, I am *not* suggesting that Ruby adopt a select! method that does something other than the opposite of reject!. I am suggesting that Ruby *not* adopt a select! method at all, because select! is (in my view) a bad name for a method that does the opposite of reject!, and having it do anything else would be confusing. > You should be able to predict how a method will work based on your > knowledge of how other, similar methods work. > > In this case it's absolutely clear. See earlier in thread -- there's been a lot of discussion and disagreement. > arr = (1..10).to_a > arr.select! { |n| n % 2 == 0 } # -> arr == [1,3,5,7,9]; self is > returned > > It's a no-brainer. Consistency is paramount! Your select! works exactly like reject!. That might be a bit too much consistency :-) David -- David A. Black dblack@wobblini.net