Vector operations doesn't convert to a common type?

simendsjo simen.endsjo at pandavre.com
Sat Apr 16 03:12:10 PDT 2011


     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]);


More information about the Digitalmars-d-learn mailing list