Parameter vs argument

Igor Wojda 🤖
Jul 29, 2017 · 2 min read

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.

Igor Wojda 🤖

Written by

Author of “Android Development with Kotlin” book 📘 working in the FinTech 💰👨‍💻industry. Follow me to learn cool things https://twitter.com/igorwojda 📈

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade