Arrays, garbage collection

Daniel Kozák via Digitalmars-d digitalmars-d at puremagic.com
Thu Jan 29 23:36:53 PST 2015


V Fri, 30 Jan 2015 01:08:30 +0000
bearophile via Digitalmars-d <digitalmars-d at puremagic.com> napsáno:
> 
> It helps avoid bugs like:
> 
> int[5] a = [1,2,4,5];
> 

No, it makes more bugs possible

// this is compile error so its ok
int[MUST_HAVE_FIVE_ITEMS] a=[1,2,3,5];
// Error: mismatched array lengths, 5 and 4


// now this is compile error so its ok
int[$] a = [1,2,3,5]; // oops I miss one value
// but there is no error at compile time



More information about the Digitalmars-d mailing list