Syntax for struct constructors

Steve Teale steve.teale at britseyeview.com
Sun Feb 7 22:11:06 PST 2010


The D2 structs and unions documentation tells how to define a struct 
constructor (that's a mouthful). But it doesn't tell how to use it. Seems 
like if you have say

struct Bar
{
    int[] a;
    this(uint sz) { a.length = sz; }
}

you can do either:

Bar bar = Bar(256);

or:

Bar bar;
bar = bar(256);

but it would be nicer if you could just do:

Bar bar(256);

In any case, it should be documented.



More information about the Digitalmars-d mailing list