From: "Marcin Mielżyński" Date: 2006-01-05T04:08:02+09:00 Subject: Re: Question on iterating a hash phil swenson wrote: > I have a hash that looks like this : {"1"=>"0, "3"="1", "45"=>"1", > "101"=>"0"} > > What I want is an array of all the keys that have hash values equal to > "1" ["3","45"] in this case. > > Yeah, i can just iterate the keys... but it seems like there is a "ruby" > way to do this. Any thoughts? > > thx > phil > {"1"=>"0", "3"=>"1", "45"=>"1","101"=>"0"}.select{|k,v| v=="1"}.map{|e|e.first} lopex