Inconsistent chain (implicitly converts to int)

Salih Dincer salihdb at hotmail.com
Sat Apr 6 10:02:31 UTC 2024


On Saturday, 6 April 2024 at 09:21:34 UTC, rkompass wrote:
>
> I checked:
>
> ```d
> import std.stdio,
>        std.range,
>        std.algorithm;
>
> struct N(T)
> {
>   T last, step, first;
>   bool empty() => first >= last;
>   T front() => first;
>   auto popFront() => first += step;
> }
>
> void main() {
>   auto r1 = N!size_t(10, 1, 1);
>   auto r2 = N!real(15, .5, 10);
> ```
> and it seems to work as I said.

Thank you for checking again, but it is important to be solution 
oriented. How about Tuple?

Yes, it might be wise to use a tuple in this case:
```d
   //...
   auto tuple = a.zip(b);
   tuple.writeln;
   // [Tuple!(int, dchar)(97, 'd'), Tuple!(int, dchar)(98, 'e'), 
Tuple!(int, dchar)(99, 'f')]

   tuple.map!(num => num[0].to!dchar).write;
   tuple.map!"a[1]".writeln; // abcdef
}
```

SDB at 79


More information about the Digitalmars-d-learn mailing list