syntax question on "invariant" keyword

Daniel919 Daniel919 at web.de
Tue Jul 3 18:52:37 PDT 2007


> struct S
> {
>     int x = 9;
>     invariant int y = 8;

Instead of it, this is working:

const int y = 8;
static invariant int y = 8;

final int y = 8; //but this takes up storage for each instance

>     void foo()
>     {
>         // y  = 7; // Expectedly, this fails to compile (GOOD).
>     }
> }

I already wrote a bug report: #1312


More information about the Digitalmars-d-learn mailing list