×

ruby · level 1 · unit 2 · 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

A is a box with a name on it.

A variable is like a box with a label. You put something in the box, write a name on the label, and from then on you say the name to get it back.

name = "Sam" puts the string "Sam" into a box called name. Whatever is inside the box is its . Read the = as put into, not equals.

To use the value, write the name with no quotes. puts name looks inside the box and shows Sam. With quotes, "name" is a string holding the word name itself.

name = "Sam"
puts name

Misspell the name and Ruby gives a NameError, because no box has that label.