Change values in hash in the same way as an array : index « Hash « Ruby






Change values in hash in the same way as an array


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


dictionary['cat'] = "fluffy 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.use square brackets to reference the element you wish to retrieve
3.Get Hash value by index
4.pulling stuff out of zip.