Array operations, dynamic arrays and length
ixid via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jun 30 15:37:33 PDT 2015
int[] a = [1,1,1,1];
int[] b = [1,1,1,1];
int[] c;
c[] = a[] - b[];
c.writeln;
This outputs []. This feels wrong, it feels like something that
should have exploded or set the length to 4. If the lengths of a
and b are mismatched it throws an exception. It also throws an
exception if a dynamic array is longer or a static array is not
the same length but is happy when a dynamic array is shorter. Is
this intended behaviour and if so why?
More information about the Digitalmars-d-learn
mailing list