Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

what are parameters and arguments?

Asked by
fifayy 28
4 years ago

Can someone explain what parameters and arguments are in functions?

3 answers

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years 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 4 years ago
Edited 4 years 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 431 Moderation Voter
4 years ago

Arguments are values, parameters are variable names.

Answer this question