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: : values_at « Hash « Ruby






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 

 








Related examples in the same category

1.values_at(key) Returns an array consisting of values for the given key(s).