Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

what are parameters and arguments?

Asked by
fifayy 16
6 months ago

Can someone explain what parameters and arguments are in functions?

3 answers

Log in to vote
0
Answered by
JesseSong 3371 Moderation Voter Community Moderator
6 months ago
Edited 6 months ago

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

Ad
Log in to vote
1
Answered by 6 months ago
Edited 6 months ago

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
--]]
Log in to vote
0
Answered by
AspectW 426 Moderation Voter
6 months ago

Arguments are values, parameters are variable names.

Answer this question