Code:
int[] make_array(int... data)
{
return data;
}
int[] test1_array = {};
int[] test1 = make_array(test1_array);
print( count( test1) );
int[] test2_array = {1, 2, 3};
int[] test2 = make_array(test2_array);
print( count( test2) );
int[] test3 = make_array(1, 2, 3);
print( count( test3) );
/*
int[] test4 = make_array({1, 2, 3});
print( count( test4) );
*/
yields
Code:
> array_literal_test
0
3
3
If I uncomment the last test:
Code:
> array_literal_test
Expected ), found { (array_literal_test.ash, line 17, char 26 to char 27)
Yes, obviously in this case, I could just use the varargs to create the array for me, but if I want to pass in an anonymous array as the not-last argument, that won't work.