[Issue 9628] Lambda in foreach loop Vs. lambda in static foreach loop

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 2 00:27:39 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9628


Maxim Fomin <maxim at maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim at maxim-fomin.ru


--- Comment #1 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-03-02 00:27:30 PST ---
Rewritten version (this can be complied with -inline):

import std.stdio, std.algorithm, std.typetuple, std.range;

auto items = [[10, 20], [30]];

void bar()
{
    foreach (int dx; 0 .. 2) {
    foreach (sub; items) {
         iota(sub.length)
         .map!((size_t i){ writeln(dx,"--", sub,"--", items); return 0; })
         .array();
    }}
}

void foo()
{
    foreach (int dx; TypeTuple!(0, 1)) {
    foreach (sub; items) {
         iota(sub.length)
         .map!((size_t i){ writeln(dx,"--", sub,"--", items); return 0; })
         .array();
    }}
}

void main() {
    bar(), writeln(), foo();
}

dx in second loop is always zero

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list