Passing a variable number of slices into a function

user1234 user1234 at 12.de
Mon Jun 22 02:04:06 UTC 2020


On Monday, 22 June 2020 at 01:47:49 UTC, repr-man wrote:
> Is there any way to pass an unknown number of slices into a 
> function?  I'm trying to do something along the lines of:
>
> void func(T)(T[] args...)
> {
>     //...
> }
>
> That wasn't working,
>
> [...]
>
> Thanks for the help!

Can you provide more details for "that wasnt working" ? because

   void func(T)(T[] args...)
   {
     writeln(args.length);
   }

   void main()
   {
     int[] a,b;
     func(a[0..$],b[0..$]);
   }

works, so there must be a missing detail.
Maybe each slice has different type ?


More information about the Digitalmars-d-learn mailing list