Learn
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]
.
Instructions
1.
Create a variable called my_array
and set it equal to the numbers 1 through 5, inclusive, in order.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.