On 07/12/2014 12:32 PM, seany wrote:

> do I have to initialize all variables of the struct?

No. The uninitialized ones get their .init values.

> or may I also use a
> this(){} in the struct and initialize only those which are known at a
> given moment?

That already works with structs. You don't need to define any constructor if the type is simple data i.e. if you don't want to set any invariants, just construct with whatever is available at that moment:

    auto a = new S("hello");

However, if it is important that someother_var should not remain as an empty array, then you better define a constructor and demand both values when constructing.

Ali

Reply via email to