use square brackets to reference the element you wish to retrieve : index « Hash « Ruby






use square brackets to reference the element you wish to retrieve


dictionary = { 'cat' => 'feline animal', 'dog' => 'canine animal' }


puts dictionary['cat']

 








Related examples in the same category

1.return a value for a given key (one key only) with the index method
2.Change values in hash in the same way as an array
3.Get Hash value by index
4.pulling stuff out of zip.