Parameters and Argument

okoth kongo
2 min readNov 22, 2018

There is unofficial confusion between arguments and parameters.This confusion is not limited to newbies like me but you will find lots of senior developers casually using these words interchangeably without remorse.Although both can be said to be two sides of the same coin(both are used in function)they are totally different things and must never be interchanged in usage. Lets dive in a little deeper:

The differences

One major difference between parameter and argument is that parameter is used in function or method definition while arguments are used in function call .For instance

def display_name(y)
y
end

when defining above method or function,display_name,we clearly state has one parameter which in this case is y.The above method can be called as fol:

display_name(‘okoth’)

the return value is

okoth

Another difference which will make you once and for all stop using them interchangeably is that parameter are variable(place holders) while argument are literals,it must be a data type.As you have seen in the example above y is a variable and during method call literal “okoth” which is a string assigned to that variable y therefore y = “okoth” during the call.to get insight on this look at these examples.

def display_name("okoth")
end

The above the code will throw an error because as I explained parameter must be a literal.

def display_name(y)
puts "My name is #{y}"
end

If you call above method like this

n = 'okoth'
displayname(n)

its return value will be as follows

My name is okoth

this is because string ‘okoth’ is assigned to variable n,making n literal(string ‘okoth’).If you call the method above with n without assigning to any literal it throw an error

In summary:

  1. Arguments are used in method or function definition while arguments are used in function or method call
  2. Parameter are variables while arguments are literal

--

--