Skip to content

Varargs in functions #36

@VariableVixen

Description

@VariableVixen

Looking at the CraftTweaker documentation for IOreDictEntry, the example for adding items indicates that varargs functions exist, as shown here:

//oreDictEnt.add(IItemStack... item_items);
oreDictEnt.add(<minecraft:grass>);
oreDictEnt.add(<minecraft:iron_ore>, <minecraft:dirt>);

However, nowhere in the documentation for custom functions is there any indication of it being possible to declare a custom function to take a varargs parameter. I tried, as a quick test, declaring a function parameter parameterName as string... (and it was not just the last but the only parameter in that function) but running /ct syntax gave me the error ) expected at that line. I also tried declaring parameterName... as string[] and got the same error.

Can custom functions be declared to take varargs parameters? If so, what is the syntax (and can it be added to the documentation)? If not, can this be implemented?

Final note: I felt this belonged in the ZenScript issue tracker because it's a feature inherent to the language, not the minecraft-specific application of it. If I'm wrong about that, I can open a copy of this on the CraftTweaker issue tracker instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions