From: Richard Lyman Date: 2002-09-22T07:20:26+09:00 Subject: Re: select and select What if the 'pick' method took an array as the first parameter, and a string as the second parameter ? The second parameter being optional that defaulted to the 'logical' choice... index for arrays, key for hashes... The second parameter being a definition of how the value supplied would match the object where the method was applied? (wow - that almost rhymed! :-) ) So:: h = { "one" => 1, "two" => 2, "different" => 2, "three" => 3, "theKeyForTwo" => "two", "anotherKeyForTwo" => "two", 3 => "three" } a = [1,2,2,3,2,4,5] valuesToPick = [ 2 ] a.pick(valuesToPick) # => 2 a.pick(valuesToPick) # => 2 valuesToPick = [ "two" ] h.pick(valuesToPick) # => 2 h.pick(valuesToPick, "value") # => "theKeyForTwo", "anotherKeyForTwo" valuesToPick= [ "two", 3 ] h.pick(valuesToPick) # => 2, "three" valuesToPick= [ 2, "three" ] h.pick(valuesToPick, "value") # => "two", "different" -Rich ----- Original Message ----- From: To: "ruby-talk ML" Sent: Saturday, September 21, 2002 9:43 AM Subject: Re: select and select > Hi -- > > On Sun, 22 Sep 2002, Dave Thomas wrote: > > > "Richard Lyman" writes: > > > > > What about a 'pick_as' option for the hash? > > > > Perhaps pick_using_xxxx, with straight 'pick' as an alias for > > pick_using_key > > Or maybe _by_ instead of _using_ ? (for brevity, also to my ear it's > a slightly better fit). > > > David > > -- > David Alan Black | Register for RubyConf 2002! > home: dblack@candle.superlink.net | November 1-3 > work: blackdav@shu.edu | Seattle, WA, USA > Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com >