I just got it! (invariant/const)
Simen Kjaeraas
simen.kjaras at gmail.com
Thu Apr 10 04:26:36 PDT 2008
On Thu, 10 Apr 2008 01:07:51 +0200, Janice Caron <caron800 at googlemail.com>
wrote:
> On 09/04/2008, Simen Kjaeraas <simen.kjaras at gmail.com> wrote:
>> class foo
>> {
>> invariant int bar;
>>
>> this()
>> {
>> bar = 4;
>> }
>> }
>>
>> This works under DMD 2.012.
>
> That's interesting. I did not know that.
I can't quite see what would be the difference between const and
invariant in this example. It's a member variable that is local
to each instance, and cannot be changed. Why should it not work?
-- Simen
More information about the Digitalmars-d
mailing list