Locked lesson.
About this lesson
What are arrays and how do we create and use them?
Exercise files
Download this lesson’s related exercise files.
Arrays.docx58.7 KB Arrays - Solution.docx
58.9 KB
Quick reference
Arrays
Arrays are containers that hold lots of things.
When to use
Use them whenever you have lists of things to store.
Instructions
To create an array:
my_array = ["John", "Tim", "Lisa"]
Items in an array are numbered, and the first item is number zero.
To call a specific item from your array, reference it's number:
puts my_array[1] - puts out Tim to the screen.
Hints & tips
- Arrays are containers that hold many items at the same time
- Items in arrays are numbered, the first item is number 0
Lesson notes are only available for subscribers.