On Thursday, May 03, 2018 22:00:04 rikki cattermole via Digitalmars-d-learn
wrote:
> On 03/05/2018 9:50 PM, ag0aep6g wrote:
> > On 05/03/2018 07:56 AM, rikki cattermole wrote:
> >>> ```
> >>> import std.stdio;
> >>> import std.range : enumerate;
> >>>
> >>> void main()
> >>> {
> >>> char[] s
On 03/05/2018 9:50 PM, ag0aep6g wrote:
On 05/03/2018 07:56 AM, rikki cattermole wrote:
```
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++;
}
On 05/03/2018 07:56 AM, rikki cattermole wrote:
```
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.
'''
On 03/05/2018 5:44 PM, James Blachly wrote:
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 =
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 =