How do you properly use immutable on class members?

Ali Çehreli acehreli at yahoo.com
Tue Mar 29 19:26:51 UTC 2022


On 3/29/22 11:59, H. S. Teoh wrote:

 > As a general principle, const should be used when you're on the
 > receiving end of data that should not be changed (e.g., function
 > parameters)

Better yet, and as I know you know :), and as it comes up occasionally 
but I usually forget in my own code; 'in' is much better than 'const' on 
function parameters because it has super powers when compiled with 
-preview=in:

   https://dlang.org/spec/function.html#in-params

Ali



More information about the Digitalmars-d-learn mailing list