From: x1 Date: 2006-12-01T12:25:32+09:00 Subject: Re: time = ["min", "sec"].collect {|i| {i=> Time.now.send(i).to_i}} Sorry --Subject was supposed to be "Need help creating hash from an array" On 11/30/06, x1 wrote: > What's the best way to make the first item below yield a hash instead > of an array in one line? I'm struggling :( > > #doesnt work > time = ["min", "sec"].collect {|i| {i=> Time.now.send(i).to_i}} > puts time.type # Array > > #works > time = ["min", "sec"].collect {|i| {i=> Time.now.send(i).to_i}}.first > puts time.type # Hash > puts time['min'] > > Thanks in advance > >