On Thursday, 8 February 2024 at 15:00:54 UTC, Kevin Bailey wrote:
By all means, please share with us how you would have written that just as elegantly but "correct".

Elegant and correct is this version:

```d
import std.stdio;

int main()
{
        char[] something = ['a', 'b', 'c'];

        writeln("len: ", something.length);
        writeln("typeid(something.length): ",
                typeid(something.length));

        writeln ("i: -1");
        foreach (i, _; something)
                writeln("i: ", i);
        return 0;
}
```

But it is still a bit too "clever" in the `foreach` statement due to the unused variable `_`.

Reply via email to