See all glossary terms

Function Parameter

A function parameter is a variable used in a function definition that acts as a placeholder for a value passed to the function when calling it.
It's a tool to parameterize a function: It allows the function to accept different values and to be more flexible.
Here's a function named heal() without any parameters:
var health := 100

func heal() -> void:
    health += 10
It always adds 10 to the health variable. But what if you want to heal by a different amount? You can use a parameter to make the function more flexible. Below, the heal() function has a parameter named heal_amount:
var health := 100

func heal(heal_amount: int) -> void:
    health += heal_amount
When calling the heal() function, we can provide a specific value for heal_amount in parentheses. In this call to the heal() function, heal_amount is set to 10:
heal(10)
When calling the function, we call the value we pass to the function an argument.
Why do they have two different names? Parameters define the type of data a function can accept. They act as placeholders for the input values that the function will use. Arguments are the actual values passed to the function when it is called. They are real data that replace the parameters' placeholders during the function's execution.

See Also

Related terms in the Glossary