×

ruby · level 1 · unit 7 · lesson 2

  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 slot where your method catches information.

Picture your method as a machine. Right now it does the same thing every time. Cut a slot in the front, and you can feed in something new on each go.

That slot is a parameter. It is a variable in the brackets of the def line, like name in def greet(name). Inside the method, use it like any other variable.

The value you drop in when you call is the . Call greet("Mia") and name holds "Mia". Call greet("Leo") and the same machine greets Leo instead.

def greet(name)
  puts "Hello, #{name}!"
end
greet("Mia")
greet("Leo")

For two slots, separate the parameters with commas, and the arguments too.