values_at(key) Returns an array consisting of values for the given key(s). : values_at « Hash « Ruby






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


h = { "a" => 100, "b" => 200, "c" => 300 }
h.values_at("a", "c")  
h.values_at("a", "c", "z")  
h.default = "cat"
h.values_at("a", "c", "z")   

 








Related examples in the same category

1.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: