Can someone explain what parameters and arguments are in functions?
✓ ANSWER ACCEPTED
what are parameters and arguments?
3 answers
✓ Accepted answer
Basically, a parameter is the variable that has been referenced by a function and an argument is iterators such as values that are passed in to an argument. If you still don't understand please click here
Note I suggest you to watch beginners to advanced series on YouTube
Here's a simple script
function addNumbers(k, b) -- parameter
print(k + b)
end
addNumbers(4, 9) -- argument
OUTPUT: 13
Parameters is a variable in the declaration of a function.
Arguments are the values that we are passing to be assigned to these variables that we declared.
-- Our function:
function addNumbers(a, b)
print(a + b)
end
addNumbers(4, 3)
--[[
We declare our parameters: a, b
We define our parameters: 4, 3
So:
a = 4
b = 3
Output: 7
--]]
Arguments are values, parameters are variable names.
This discussion is preserved as it was. New answers, comments, and votes are closed.
