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

w0rp devw0rp at gmail.com
Fri Mar 28 05:58:42 PDT 2014


On Thursday, 27 March 2014 at 10:30:59 UTC, ketmar wrote:
>> 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

I reckon that is a bug, and it should be legal. Perhaps someone 
else will know more.


More information about the Digitalmars-d mailing list