sorting a string
ag0aep6g via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 14 22:35:43 PDT 2017
On 07/15/2017 04:33 AM, Namal wrote:
> Why does it have to be char[]?
>
> auto bytes = line.representation.dup;
> bytes.sort;
> string result = bytes.assumeUTF;
>
> works too.
That's a compiler bug. The code should not compile, because now you can
mutate `result`'s elements through `bytes`. But `result`'s elements are
supposed to be immutable.
I've filed an issue: https://issues.dlang.org/show_bug.cgi?id=17654
More information about the Digitalmars-d-learn
mailing list