Error: function `...` without `this` cannot be `const`

jfondren julian.fondren at gmail.com
Wed Jun 30 20:53:34 UTC 2021


On Wednesday, 30 June 2021 at 20:12:29 UTC, H. S. Teoh wrote:
> On Wed, Jun 30, 2021 at 07:40:40PM +0000, someone via 
> Digitalmars-d-learn wrote: [...]
>>     @property int data() { return m_data; } // read property
> [...]
>> string something() @property { return this.whatever; }
> [...]
>> Now I am not sure which is the correct way.
> [...]
>
> Both are correct. :-)  It's up to personal style preference.
>
>
> T

@nogc unittest { } // works
unittest @nogc { } // doesn't work

https://dlang.org/dstyle.html doesn't suggest either way, but
does suggest alphabetical ordering(!) which I hadn't noticed.


More information about the Digitalmars-d-learn mailing list