Privatize a few members to allow messing with them #11353

matheus matheus at gmail.com
Tue Jun 30 20:28:14 UTC 2020


On Tuesday, 30 June 2020 at 20:01:43 UTC, Stanislav Blinov wrote:
> On Tuesday, 30 June 2020 at 19:58:05 UTC, matheus wrote:
>
>> +            loc.linnum = loc.linnum + incrementLoc;
>>
>> This works because it was declared:
>>
>> void linnum(uint rhs) { _linnum = rhs; }
>>
>> Right?
>
> Almost. Given these definitions:
>
> @safe @nogc pure @property
> {
>     const uint linnum() { return _linnum; }
>     void linnum(uint rhs) { _linnum = rhs; }
> }
>
> This:
>
> loc.linnum = loc.linnum + incrementLoc;
>
> is rewritten as:
>
> loc.linnum(loc.linnum() + incrementLoc);

Alright and thanks again.

Matheus.


More information about the Digitalmars-d-learn mailing list