From: Dirk Traulsen Date: 2008-01-31T04:24:14+09:00 Subject: Re: Proposal/RFQ: Hash#values/keys with block Am 30 Jan 2008 um 23:20 hat tho_mica_l geschrieben: > > Intuitively for me > > hash.keys {|k,v| v > 200 } > > #keys should return the hash's keys, IMHO it shouldn't iterate over > these keys. How could you return the keys without iterating over them? > If you want to reject certain keys, call reject on these keys > as returned. The phrase "reject certain keys" put into the right > order would be in ruby lingo: hash.keys.reject {|k| hash[k] > 200} Yes and there are some other possibilities to achieve the same. But this is not the point. > If you think these methods are valuable, Enumerable is an open > module and you can add new methods at any time. I know that! How can one program in Ruby and _not_ know that classes and modules are open? This proposal is about the extension of two methods that are already in the standard lib (in Hash, not Enumerable). I'm arguing in favour of this extension of these Hash methods because for me, it would be the Ruby way to solve for example the following problem: "Give me the keys of the hash with a value over 200." hash.keys {|k,v| v > 200 } Sure can this be solved in several other ways, but I think this would be the most direct and intuitive way. For me the Ruby way. Therefore and because of the other reasons I gave in another mail in this thread I think this would be avaluable addition to the standard lib. Please, everybody post your opinions. I would especially be happy if somebody would express some support to my position... Dirk