If a method takes arguments, we say it accepts or expects those arguments. We might define a function, square, like so:

def square(n) puts n ** 2 end

and call it like this:

square(12) # ==> prints "144"

The argument is the piece of code you actually put between the method’s parentheses when you call it, and the parameter is the name you put between the method’s parentheses when you define it. For instance, when we defined square above, we gave it the parameter n (for “number”) and passed it the argument 12 when we called it.

You can think of parameters as placeholders the method definition gives to arguments since it doesn’t know ahead of time exactly what argument it’s going to get.

Parentheses are usually optional in Ruby, but it’s a good idea to put your parameters and arguments in parentheses for readability.



Call the cubertino method in the editor, passing it an argument of 8.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?