Deprecation: foreach: loop index implicitly converted from size_t to int
BoQsc
vaidas.boqsc at gmail.com
Sun May 12 00:35:16 UTC 2024
A horrible alternative would be to use `alias` on `size_t` to
make up a new pseudo-type that is more aligned with the code
logic.
```
alias integer = size_t;
import std.stdio : writefln;
void main() {
auto arr = [
[5, 15], // 20
[2, 3, 2, 3], // 10
[3, 6, 2, 9], // 20
];
foreach (integer i, row; arr)
{
double total = 0.0;
foreach (e; row)
total += e;
auto avg = total / row.length;
writefln("AVG [row=%d]: %.2f", i, avg);
}
}
```
More information about the Digitalmars-d-learn
mailing list