.init of field == type's initializer or field initializer?

Andrej Mitrovic none at none.none
Thu May 19 20:19:17 PDT 2011


From: http://d-programming-language.org/property.html
.init Property:
".init produces a constant expression that is the default initializer. If applied to a type, it is the default initializer for that type. If applied to a variable or field, it is the default initializer for that variable or field. For example: "

struct Foo
{
    int a;
    int b = 7;
}

Foo.a.init	// is 0
Foo.b.init	// is 7

Foo.b.init is actually 0. Are the docs wrong, or is the compiler wrong? Let me know so I can fix the docs if necessary as I'm doing that now.


More information about the Digitalmars-d-learn mailing list