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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -