Get Hash value by index : index « Hash « Ruby






Get Hash value by index


myHash = { 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five" }
myHash[6]= "Six"
myHash[2]= "Bent"

 








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.pulling stuff out of zip.