Strange behavior of iota

bachmeier no at spam.net
Tue Feb 15 21:48:29 UTC 2022


This code

```
import std.conv, std.range, std.stdio;

void main() {
     auto v = [1, 2, 3, 4, 5];
     writeln(iota(v.length,-1,-1));
     writeln(iota(v.length,-1.to!long,-1));
     writeln(iota(v.length.to!int,-1,-1));
     writeln(iota(v.length.to!uint,-1,-1));
     writeln(iota(v.length.to!ulong,-1,-1));
}
```

outputs

```
[]
[]
[5, 4, 3, 2, 1, 0]
[]
[]
```

Why does the first argument to iota have to be an int, and why 
isn't there an error message when I pass something else?


More information about the Digitalmars-d-learn mailing list