Variadic Functions
Variadic functions can be called with any number of trailing arguments.
main.w
// Function that will take an arbitrary number of ints as arguments.
let plus = (...numbers: Array<num>) => {
let var value = 0;
for number in numbers{
value = value + number;
}
return value;
};
// in this example you can pass any many numbers as you want
log(plus(1, 2));
log(plus(1, 2, 3));
log(plus(1, 2, 3, 4));
Wing console output
# Run locally with wing console
wing it
3
6
10