Why can't function expecting immutable arg take mutable input?

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 16 04:33:03 PDT 2015


On Friday, 16 October 2015 at 10:35:23 UTC, Shriramana Sharma 
wrote:
> I understand that const can refer to either mutable or 
> immutable, so does this mean I should replace all occurrences 
> of `string` in arguments and return values of functions by 
> `const(char)[]`?

Use `inout` attribute for that: take inout(char)[] parameter and 
return inout(char)[] result.


More information about the Digitalmars-d-learn mailing list