Loops & Iterators

Saving Multiple Values

Let's say we want to save a range of numbers in a variable. How would we do this? A variable can only hold a single value, right?

In Ruby, we can pack multiple values into a single variable using an array. An array is just a list of items between square brackets, like so: [1, 2, 3, 4]. The items don't have to be in order—you can just as easily have [10, 31, 19, 400].

Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.