to auto or not to auto ( in foreach )

cym13 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 16 07:11:34 PDT 2016


On Saturday, 16 July 2016 at 14:00:56 UTC, dom wrote:
> foreach(auto v; msg)
>   writeln(v);
>
> gives an error that a basic type is expected
>
> foreach(v; msg)
>   writeln(v);
>
> works
>
> .. but why?

Arbitrary limitation. If you want to say how surprising and 
uselessly limiting it is wait at the end of the line.

It's not actually a problem in practice because you just have not 
to put it but it is part of those frustrating little edge cases 
with no reason to be.


More information about the Digitalmars-d-learn mailing list