vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
555 stars 92 forks source link

An issue with rest arguments of T[][] #272

Closed justonlyasy closed 3 years ago

justonlyasy commented 3 years ago

Check it,

// This function sums its arguments.
real sum(... real[][] nums) {
real total=0;
for(int i=0; i < nums.length; ++i)
total += sum(nums[i]);
return total;
}

write(sum(... new real[][]{{1,2},{3,4}})); // outputs: 10
write(sum({1,2},{3,4})); // syntax error
johncbowman commented 3 years ago

If you fix the syntax error, you will get the correct output:

`// This function sums its arguments. real sum(... real[][] nums) { real total=0; for(int i=0; i < nums.length; ++i) total += sum(nums[i]); return total; }

write(sum(... new real[][]{{1,2},{3,4}})); // outputs: 10 write(sum(new real[] {1,2}, new real[] {3,4})); // outputs: 10 `