I have the following piece of code:

``````````````````````
#!/bin/env dub
/+ dub.sdl:
    name: day2
+/
import std.algorithm.iteration : group;
import std.stdio;

void main() {
    const auto a = group("simon");
    auto b = group("simon");
    writeln(a == b);
    writeln();
    writeln(a);
    writeln();
    writeln(b);
}
``````````````````````

When I run it, it gives me this output:

``````````````````````
true

const(Group!("a == b", string))("imon", Tuple!(dchar, uint)('s', 1))

[Tuple!(dchar, uint)('s', 1), Tuple!(dchar, uint)('i', 1), Tuple!(dchar, uint)('m', 1), Tuple!(dchar, uint)('o', 1), Tuple!(dchar, uint)('n', 1)]
``````````````````````

The only difference (code-wise) is the `const` keyword. I've tried with both `ldc` and `dmd` with same result. Why is the output different when the variable is `const`?

Reply via email to