Locked lesson.
About this lesson
An array of other arrays is multi-dimensional.
Exercise files
Download this lesson’s related exercise files.
Multi-Dimensional Arrays.docx60.1 KB Multi-Dimensional Arrays - Solution.docx
59 KB
Quick reference
Multi-Dimensional Arrays
A multi-dimensional array is an array with other arrays inside of it.
When to use
Use it whenever you need to put arrays inside of other arrays!
Instructions
Arrays can hold just about anything; strings, numbers, variables, other arrays and many other things.
To creatte a multidimensional array:
my_array ["John", "Tim", "Mary", ["Elder", "Smith", "Jones"]]
To call an item inside an array that's inside an array:
puts my_array[3][1] - puts Smith
Hints & tips
- Arrays can hold all types of items!
- An array with other arrays inside is called a multi-dimensional array
Lesson notes are only available for subscribers.