Click here to navigate the course.

Drag the edges to resize the window.

Code Editor
Data Structures

Adding to a Hash

We can add to a hash two ways: if we created it using literal notation, we can simply add a new key-value pair directly between the curly braces. If we used, we can add to the hash using bracket notation:

pets = pets["Stevie"] = "cat" # Adds the key "Stevie" with the # value "cat" to the hash
Report a Bug
If you see a bug or any other issue with this page, please report it here.