Closures and loop scope
Nick Sabalausky
SeeWebsiteToContactMe at semitwist.com
Tue Jun 4 15:17:41 PDT 2013
On Tue, 04 Jun 2013 23:48:32 +0200
Timon Gehr <timon.gehr at gmx.ch> wrote:
>
> Behind the scenes, the foreach loop is rewritten to something like:
>
> for(int __a=0;__a<5;__a++){
> int a = __a;
> writeln(&a);
> }
Yea, I think the years I spent using C has corrupted my brain into
seeing...
foreach(int a; 0..5)
...as shorthand for:
for(int a=0; a < 5; a++) { /* use a */ }
Which is something I wrote far too many times in the 90's ;)
More information about the Digitalmars-d
mailing list