What is an Argument, What is a Parameter in Ruby ?

Yahya Gok
2 min readJun 26, 2021

Parameter is a keyword that we use when we define a method in Ruby. Simply, in below example; name in parentheses is a parameter. Parameter could be anything, it could be a hash, it could be an array, string, number. We could add as many parameters as we want. We use parameters because we need to pass some data to our defined method.

Like here, I need to add a name to run this function properly and dynamically. So that I could be able to change this name with another name that whatever I want if I need to run my code for other name. So name should be coming from outside of this method.

So name could be a variable that defined outside of this method, or could be coming from invocation which means that when I invoked this method I do like this;

on line 27, we invoked the function and put a string in a parentheses, this string fulfills name in the method.

put_your_name(“yahya”), this “yahya” represents argument. When calling the method and passing in a value, the value passed in is referred to as an argument.

Resources

--

--