From: "David A. Black" Date: 2005-10-08T07:53:04+09:00 Subject: Re: select! not present but reject! is Hi -- On Sat, 8 Oct 2005, Rob Rypka 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. > > select and reject (without the exclamation marks) are Ruby opposites, > though. Nobody seems opposed to that. I hadn't thought we were talking about them. They seem OK to me, though I could imagine reject actually being an in-place operation even without the !. > If I had two methods, Array#foo and Array#foo!, I would expect the > definition of foo! to be: > > "Same as Array#foo, but modifies the receiver in place." See below about !, but also: I question what "select a subarray from an array, in place" means. It sounds to me like the selected subarray is *removed* from the array. Replacing the array with the selected subarray seems to me to be a second transaction, not a select operation per se. > Sometimes, the above leads to another (near) synonym (like delete_if > and reject!), but the The return value should be the receiver, > instead of a new array. To me, foo! doesn't mean finding a new > meaning of the foo operation in a way that would be destructive, it > means immediacy to the receiver (which in turn implies destruction). > "Select these elements, but alter your contents and return yourself, > instead of someone new." The ! doesn't mean that a method modifies the receiver in place, though, but rather that this is a "dangerous" version of the method and should be used carefully. The "danger" often has to do with in-place change, but ! itself doesn't mean that. David -- David A. Black dblack@wobblini.net