inout after function
Dave Jones
dave at jones.com
Sun Nov 26 11:33:16 UTC 2017
On Sunday, 26 November 2017 at 04:51:08 UTC, Adam D. Ruppe wrote:
> On Sunday, 26 November 2017 at 01:35:01 UTC, Dave Jones wrote:
>> So it makes it a const/immutable/mutable method depending on
>> whether the instance it is called on is
>> const/immutable/mutable?
>
> On the outside, yes.
>
>> So
>>
>>> @property ref inout(int) front() inout {
>>> return i++;
>>> }
>>
>> Would fail if you called it on an immutable instance of S.
>
> That wouldn't compile in any case: on the inside of the
> function, inout == const (this is the only way the one function
> can be used for all three). The inout propagation is just seen
> at the call site.
Ahh ok, makes sense now.
More information about the Digitalmars-d-learn
mailing list