-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Since CraftTweaker 4.1.20.668, ZenScript supports default arguments
This means that you can do:
function foo(a as int, b as int = 2, c as int = 3) as void {
print(a + b + c);
}
foo(1); // print 6 [1 + 2 (default) + 3 (default)]
foo(1, 3); // print 7 [1 + 3 + 3 (default)]
foo(1, 1, 4); // print 6 [1 + 1 + 4]
Note 1: You can use bracket handlers and functions for default arguments. But variables are not allowed. Currently, they areseen as strings, but may produce parse exception in the future version.
Note 2: Once a parameter have a default argument, the parameters after it also require a default argument.
—— From friendlyhj
As yet, there is no corresponding syntax parsing for this function, and it is hoped that it will be added in the new version.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request