pulling stuff out of zip. : index « Hash « Ruby






pulling stuff out of zip.


# Here is a simple way of grabbing a value: the [] method. 
# It retrieves a single hash value based on a key:

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


zip[1] # => "One"

 








Related examples in the same category

1.return a value for a given key (one key only) with the index method
2.use square brackets to reference the element you wish to retrieve
3.Change values in hash in the same way as an array
4.Get Hash value by index