I am puzzled why enumerating in a foreach returns a dchar (which forces me to cast), whereas without the enumerate the range returns a char as expected.

Example:

```
import std.stdio;
import std.range : enumerate;

void main()
{
        char[] s = ['a','b','c'];

    char[3] x;
    auto i = 0;
    foreach(c; s) {
        x[i] = c;
        i++;
    }

    writeln(x);
}
```
Above works without cast.

'''
import std.stdio;
import std.range : enumerate;

void main()
    {
        char[] s = ['a','b','c'];

    char[3] x;
    foreach(i, c; enumerate(s)) {
        x[i] = c;
        i++;
    }

    writeln(x);
}
```
Above fails without casting c to type char.

The function signature for enumerate shows "auto" return type, so that does not help me understand.

Kind regards

Reply via email to