Varargs (Variable Arguments)

Varargs in Jai are denoted with two periods (..).

When used to declare a function parameter (foo :: (args : ..) {}), they collect zero or more arguments into an array of type Any. 1

varargs :: (args : ..) {
  // compiler declares args as: [] Any;
  printf("%d arguments.\n", args.count);
}

When used to send an array parameter to a function (foo(..args);), they spread the array elements out as individual arguments. 2

letters : [] string = ["a", "b", "c"];
varargs(..letters); // prints: "3 arguments"
}

  1. Variable argument functions are denoted with two dots: ... The vararg collects the last zero or more arguments to the function into an array of type Any.
    “Demo: Run-Time (and Compile-Time) Type Information” YouTube, uploaded by Jonathan Blow, Feb 11, 2015, https://youtu.be/JoNkttD_MUs?t=1083 

  2. Variable argument functions can accept an array as the varargs value, and spread the array elements out as individual arguments.
    “Demo: Run-Time (and Compile-Time) Type Information” YouTube, uploaded by Jonathan Blow, Feb 11, 2015, https://youtu.be/JoNkttD_MUs?t=1615 

jailang 2019 pixeldroid
https://github.com/pixeldroid/jailang
programming pages theme v0.5.21 (https://github.com/pixeldroid/programming-pages)