Detect the bug in the following code

Caspar via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 15 10:44:06 PDT 2015


On Wednesday, 15 April 2015 at 17:28:01 UTC, John Colvin wrote:
> On Wednesday, 15 April 2015 at 14:44:48 UTC, Idan Arye wrote:
>> import std.stdio;
>>
>> struct Foo {
>>    bool registered = false;
>>
>>    void register(int x) {
>>        writeln("Registering ", x);
>>        register = true;
>>    }
>> }
>>
>> void main() {
>>    Foo foo;
>>    foo.register(10);
>> }
>
> Property assignment syntax for non-property functions is a 
> horrible, horrible thing.

Could someone please explain what is actually happening in that 
piece of code to a D newbie?
I see what happens when I run the code but I don't get why it is 
happening.
In particular what "register = true;" actually does in that case.

Thanks,
Caspar


More information about the Digitalmars-d mailing list