Prevent Garbage Collector

Jacob Carlborg doob at me.com
Sun Jan 5 01:42:38 PST 2014


On 2014-01-05 01:17, Jeroen Bollen wrote:
> Also a somewhat unrelated question, variables in D get initialized by
> default, do they also when you define them right after? Something like:
>
> int[] iryy = new int[](50); // Will the array elements be initialized to 0?

Yes, have a look at:

http://dlang.org/arrays.html#array-initialization

This example verifies the behavior:

int[] iryy = new int[](50);
assert(iryy[3] == 0);

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list