Discord
Login
Community
DARK THEME

Function Arguments List

Every time someone calls a function, a local list would get called named function.arguments, this makes the user be able to use function.arguments.length.Example:

myFunction = function(num1,num2,num3)
  if myFunction.arguments.length == 2 then
    num1 + num2
  elsif myFunction.arguments.length == 3 then
    num1 + num2 + num3
  end
end

This is just an example.

Unless this exists.

This can be used in vector library.

The suggestion to get access to the arguments list is a good one, I will definitely look into it.

Note that your example could also be implemented using default values for your arguments:

myFunction = function(num1,num2,num3=0)
  num1 + num2 + num3
end

(if num3 is not provided when the function is called, it will be set to zero by default)

But there are many other cases where access to the arguments list could actually be useful.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community