From: dblack@... Date: 2007-01-21T23:00:28+09:00 Subject: Re: Hash pairs at? Hi -- On Sun, 21 Jan 2007, gga wrote: > > gga wrote: >> Trans ha escrito: >>> Seesm like there should be a mehtod for this: >> >> No. >> > > That being said, Hash DOES seem to be buggy and missing a proper > find_all method. > > irb> h.find_all { |k,v| [:a,:c].include?(k) } > => [[:c, 3], [:a, 1]] # incorrect, it is returning an array, not a > hash It's not incorrect or buggy; that's the way Enumerable#find_all works. In addition to being Enumerables themselves, arrays serve as the common container for the results of lots of different Enumerables. It could work otherwise (at least for hashes, though not in the general Enumerable case), but it works this way by design, not by accident. David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)