adds the value "Six" with a key 6. Or you can use []= to change a value : Hash Elements « Hash « Ruby






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


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


myHash[2]= "Bent"

 








Related examples in the same category

1.Changing Hashes
2.changes the value associated with the key 2 to "Bent".