From: Robert Klemme Date: 2008-01-29T22:50:23+09:00 Subject: Re: Proposal/RFQ: Hash#values/keys with block 2008/1/29, Thomas Wieczorek : > On Jan 29, 2008 2:10 PM, Dirk Traulsen wrote: > > hash.keys {|k,v| k.size == 1 } #=> ["a", "c"] > > Same here: > hash.keys.select {|el| el.size == 1 } Additional note: If selection needs to be done on key and value you can do this: hash.select {|k,v| k.size == 1 }.map {|k,v| k} or irb(main):006:0> hash.inject([]) {|ks,(k,v)| ks << k if k.size == 1; ks} => ["a", "c"] > > Well, I would prefer the extension of Hash#keys/values with blocks. > > What do you think? I am waiting to see whether this is generally needed. As far as I remember this has not been suggested before. If there is no overwhelming request for this I opt for not making this standard. Kind regards robert -- use.inject do |as, often| as.you_can - without end