Is there a function to change the following array (basically to remove “str” and “=>” and “value”)
[{"str"=>"abc", "value"=>1}, {"str"=>"efg", "value"=>2}, {"str"=>"hij", "value"=>3}]
to something like this:
[[abc, 1], [efg, 2], [hij,3]]
Thanks for your help
This works for the array you gave.
If you want a general solution, you’ll have to specify more requirements. A hash’s entries are not ordered (well, they do maintain order in ruby 1.9, but it’s not good practice to rely on this), so you can’t simply grab the values via
hash.values, unless you really don’t care about the ordering.