how would D be different if string were const(char)[]?

Dicebot public at dicebot.lv
Thu Oct 17 06:22:22 PDT 2013


Small example, this is valid D:

void main()
{
    char[] mut = "aaa".dup;
    const(char)[] str = mut;
    mut[1] = 'b';
    assert (str == "aaa"); // oops
}


More information about the Digitalmars-d-learn mailing list