Mega Code Archive

 
Categories / Ruby / Hash
 

Retrieve the values out of a hash based on one or more keys with values_at, also placing the value or values in an array

zip = { 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five", 6 => "Six", 7 => "Seven", 8 => "Eight", 9 => "Eight" } puts zip.values_at 5  puts zip.values_at 1, 4, 7