return a value for a given key (one key only) with the index method : index « Hash « Ruby






return a value for a given key (one key only) with the index method


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


zip.index "Three" # => 3

 








Related examples in the same category

1.use square brackets to reference the element you wish to retrieve
2.Change values in hash in the same way as an array
3.Get Hash value by index
4.pulling stuff out of zip.