simendsjo: > int[3] a = [1,2,4]; > float[3] b = [1,2,4]; > float[3] c; > // Why doesn't this work? > c = a[] + b[]; // Error: incompatible types for ((a[]) + (b[])): > 'int[]' and 'float[]'
> // When this works? > c[0] = a[0] + b[0]; > c[1] = a[1] + b[1]; > c[2] = a[2] + b[2]; > assert(c == [2,4,8]); Vector ops are often implemented in assembly, and despite they are less flexible, they sometimes lead to more efficiency (if the arrays are large). The second example uses normal D code, that's much more flexible. Bye, bearophile