changes the value associated with the key 2 to "Bent". : Hash Elements « Hash « Ruby






changes the value associated with the key 2 to "Bent".


# you can use the store method to add a pair to the myHash array

myHash = { 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four",
5 => "Five" }

myHash.store(6, "Six")

 








Related examples in the same category

1.Changing Hashes
2.adds the value "Six" with a key 6. Or you can use []= to change a value