×

ruby · level 1 · unit 6 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

An keeps many values together, in order.

An array is like a shopping list: many values kept together, in order, in one variable. Write it with square brackets, and put a comma between each .

Each value in an array is an item. Items can be strings, numbers or a mix. .length tells you how many items there are, the same way it counts letters in a string.

To see a whole array, use . It shows the array the way you would write it, brackets and quotes included. puts shows each item on a line of its own instead.

snacks = ["crisps", "apple", "popcorn"]
p snacks
puts snacks.length
puts snacks

An empty array, [], is a list with nothing on it yet.