Reputation: 909
I want to be able to take the following:
{"6"=>"", "7"=>"104", "8"=>"", "9"=>"", "0"=>"Testing", "2"=>"1", "3"=>"", "10"=>"Testing", "4"=>"1", "5"=>""}
and convert it into
[["","104","","","Testing"........], ["" ......]
Thank you
Upvotes: 1
Views: 127
Reputation: 4809
The Hash class has the method values
which returns an array of all the values.
my_hash = {"6" => "", "7" => "104"}
my_array_of_values = my_hash.values # ["", "104"]
In Ruby, the Hash contains key/value pairs (eg. { key => value }). The keys
method returns an array of the keys and the values
method returns an array of the values.
Read more about the values method here: http://ruby-doc.org/core/classes/Hash.html#M002867
Upvotes: 4