×

ruby · level 1 · unit 2 · lesson 4

  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

lets your program ask a question.

gets is like a waiter taking your order. Your program stops and waits while the person types an answer and presses Enter. Then gets hands back what they typed, as a string.

Show the question first with print, so the answer goes on the same line. Then store the answer in a variable: .

Pressing Enter leaves an invisible new line on the end of the answer. .chomp bites it off. Without it, anything you join after the answer drops onto the next line.

Leave a space at the end of your question, inside the quotes, so the answer does not bump into it.