From: dblack@... Date: 2006-01-05T05:14:43+09:00 Subject: Re: Question on iterating a hash On Thu, 5 Jan 2006, Kevin Olbrich wrote: >> Wouldn't it be easier to iterate through the keys? I'm not sure why >> Phil didn't want to. (Phil?) >> >> h.keys.select {|k| h[k] == 1} >> > > Since he wants the keys of the hash in an array, wouldn't you need to do > this.. > > result = h.keys.select {|k| h[k] == 1} > result = result.keys No. h.keys is an array, and select returns an array. David -- David A. Black dblack@wobblini.net "Ruby for Rails", from Manning Publications, coming April 2006! http://www.manning.com/books/black