Adding elements to a hash

First, we are going to see how to add items to a hash. To do that, add in the following code:

people[:leann] = 42 

Now, if you type people, you can see this new element has been successfully added:

So adding to a hash is similar to adding to arrays. But instead of passing in an index and value, you supply a key and then a value.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.157.6