From: "David A. Black" Date: 2008-08-01T19:17:46+09:00 Subject: [ruby-core:18051] Re: New array methods cycle, choice, shuffle (plus bug in cycle) Hi -- On Fri, 1 Aug 2008, Charles Oliver Nutter wrote: > Michael Neumann wrote: >> For me as a non-native English speaker, #choice is clearer. >> For me, #choose implies that *I* have to choose something, i.e. I would >> expect that method #choose has a parameter, which it doesn't have. >> Whereas #choice implies, that I have no choice, which is in some sense >> true for this method, because I can't choose the element I want. >> >> So in contrast to Charles, I think, ary.choice produces a choose >> operation internally :) > > I think it's pretty standard to have imperative verb methods be addressed to > the object in question. IO#write is telling the IO object to write something. > Enumerable#map is telling the Enumerable to produce a new array based on the > results of eaching to your block. String#split tells the array to split based > on your criteria. In almost all cases where a verb is specified, it's an > order (or message, eh?) to the object in question. Choose is the same. In all those other examples, though, something follows the verb: write this, split on this, map to this block, etc. And I do think it's a problem that "choose" is so similar to "select". But for me the biggest problem is that neither "choose" nor "choice" contains the slightest implication of randomness. It might as well be called fred. If Python has "choice" to mean a random array element, then this is a good opportunity for Ruby to be "a better Python" :-) So I'd definitely want to see it changed to #rand (or something else that denotes randomness, though #rand would be perfectly fine). I doubt the method will be used very often anyway -- but all the more should it really say what it's doing and not have a cryptic or ambiguous name. David -- Rails training from David A. Black and Ruby Power and Light: * Advancing With Rails August 18-21 Edison, NJ * Co-taught by D.A. Black and Erik Kastner See http://www.rubypal.com for details and updates!