Arrays are a common data structure that can be utilized in Ruby programs to store a collection of data types, including: integers, floats, strings, and more.
Now that we know how to create an array and add elements to it, we are now going to see how to delete items from it.
A popular way to work with arrays is to push and pop elements. Pushing is when you add an element to the end of the array while popping is when you pop that item off the array. It's similar to inserting and deleting, except that it happens at the end of the array.
For complex collections, the **Hash data structure** is a powerful tool in Ruby programs. Hashes are **key/value** based and let you access data elements with more than a pure index, such as with arrays.
In this lesson, you'll learn how to delete from a Ruby hash.
We have already learned how to iterate through a hash in one of our previous lessons, however it's a very critical task that you'll be using quite often, so I'm going to go discuss how it works in more detail. Also, I'm going to show you how you can iterate over just a key or a value.
Since hashes are an integral part of Ruby, I want to go through some helpful methods that can be quite handy in development.
devCamp does not support ancient browsers.
Install a modern version for best experience.