X
x1
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
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