for, foreach identifier allowed in c throws error in d

Logesh Pillay via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 2 13:08:10 PDT 2014


Sorry, I am embarassed to say I've just tried the for equivalent 
and it works with t[i] as the iterating variable.

import std.stdio;

int[3] t;

void foo (int i) {
   if (i == 3)
     writef("%s\n", t);
   else for (t[i] = 0; t[i] < 3; t[i]++)
     foo(i+1);
}

void main() {
   foo(0);
}

Sorry, yet another overhasty post


More information about the Digitalmars-d-learn mailing list