ruby: how to convert hash into array -
i have hash contains numbers such:
{0=>0.07394653730860076, 1=>0.0739598476853163, 2=>0.07398647083461522}
it needs converted array like:
[[0, 0.07394653730860076], [1, 0.0739598476853163], [2, 0.07398647083461522]]
i tried hash.values gets me:
[0.07398921877505593, 0.07400253683443543, 0.07402917535044515]
i have tried multiple ways started learning ruby.
try this:
{0=>0.07394653730860076, 1=>0.0739598476853163, 2=>0.07398647083461522}.to_a #=> [[0, 0.07394653730860076], [1, 0.0739598476853163], [2, 0.07398647083461522]]
Comments
Post a Comment