Parameter vs argument

This post is part of Code building blocks series that focus on various elements and concepts of programming languages.

There is some confusion about argument and parameter and some programmers use this term alternately. There is however important distinction between those two terms.

Parameter

The parameter is a special kind of variable declared in the function signature. It is a placeholder that is used to access function input data (argument). Let’s look at an example. Below function defines two parameters a and b.

fun sum(a:Int, b:Int): Int {
return a + b
}

Argument

The argument, on the other hand is the actual value passed to a function when the function is called. We can say that function defines parameters and it takes arguments.

sum(1 ,4)

When sum function is called parameters (a, b) are substituted with corresponding arguments (1, 4).

We can think about the argument as value/reference that is passed to a function while parameters are values ‘received’ by a function.

Summary

At first difference between parameters and arguments may be a little confusing, but now you should be able to easily distinguish both concepts.

To learn about other concept and conductus take a look at Code building blocks series.