Modify char in string

Tim via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 18 11:55:57 PDT 2014


Hi everyone,

is there any chance to modify a char in a string like:

void main()
{
    string sMyText = "Replace the last char_";
    sMyText[$ - 1] = '.';
}

But when I execute the code above I'm always getting "cannot 
modify immutable expression at sMyText[__dollar -1LU]". I though 
D supported such modifications anytime. How can I do that now...?


More information about the Digitalmars-d-learn mailing list