foreach: How start a foreach count with specific number?
Ali Çehreli
acehreli at yahoo.com
Wed Jun 2 16:06:30 UTC 2021
On 6/2/21 8:49 AM, Marcone wrote:
> But I don't want it starts with 0, but other number. How can I do it?
It is not configurable but is trivial by adding a base value:
import std.stdio;
enum base = 17;
void main() {
auto arr = [ "hello", "world" ];
foreach (i, str; arr) {
const count = base + i;
writefln!"%s: %s"(count, str);
}
}
Ali
More information about the Digitalmars-d-learn
mailing list