why foreach() don't use 'auto'?

ketmar ketmar at ketmar.no-ip.org
Thu Mar 27 03:30:58 PDT 2014


> You can use `auto` in foreach, as well as any explicit type. It 
> can be omitted because it is unambiguous.
no, i can't. at least in current GDC.

import std.stdio, std.string;

void main () {
     foreach (auto val; [0,1,2,3]) writeln(val);
}

error: basic type expected, not auto


More information about the Digitalmars-d mailing list