Calls to struct methods and immutable

bearophile bearophileHUGS at lycos.com
Thu Nov 15 06:08:38 PST 2012


> /*
>      this(int a, int b) {
>          this.a = a;
>          this.b = b;
>      }
> */
>
>      void check() const pure nothrow {
>          immutable real p = a ^^ 2 + b ^^ 2;
>          assert(sqrt(p) < 10);
>      }
> }

If you keep the constructor, then it's probably better to replace 
check() with an invariant().

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list