function with multiple default arguments
Posted: Sat Aug 05, 2017 5:56 pm
Not sure why I can't find this question anywhere. I feel like I'm missing something obvious.
Assume there is a function like this:
Since both 'b' and 'c' have defaults, I'm guessing there isn't a way to set 'c', but leave b as default?
Because myFunc(10,20) would set a and b, and leave c as default. Or can you use some type of explicit assignment, like this... myFunc(10,c=20) ?
Assume there is a function like this:
Code: Select all
function myFunc(a,b,c)
b = b or 10
c = c or -1
print (a,b,c)
end
Because myFunc(10,20) would set a and b, and leave c as default. Or can you use some type of explicit assignment, like this... myFunc(10,c=20) ?