varargs when they're not all the same type?

monkyyy crazymonkyyy at gmail.com
Thu Mar 14 18:03:14 UTC 2024


On Thursday, 14 March 2024 at 17:57:21 UTC, Andy Valencia wrote:
> Can somebody give me a starting point for understanding varadic 
> functions?  I know that we can declare them
>
>   int[] args...
>
> and pick through whatever the caller provided.  But if the 
> caller wants to pass two int's and a _string_?  That 
> declaration won't permit it.
>
> I've looked into the formatter, and also the varargs 
> implementation.  But it's a bit of a trip through a funhouse 
> full of mirrors.  Can somebody describe the basic language 
> approach to non-uniform varargs, and then I can take it the 
> rest of the way reading the library.
>
> Thanks in advance!
> Andy

there are 3 (or 4?) variadic functions
try
```d
auto foo(T...)(T args){
   static foreach(arg;args){
     ...
```


More information about the Digitalmars-d-learn mailing list