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

           Summary: Hash iteration should support counter variable
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Andrej Mitrovic <[email protected]> 2013-04-03 
12:10:58 PDT ---
void main()
{
    string[string] hash;
    foreach (i, key, val; hash)  // ng
    {
    }
}

I think it would be nice to support this, it allows for things like:

void main()
{
    string[string] hash = ["foo":"1", "bar":"2"];

    string res;
    foreach (i, key, val; hash)  // ng
    {
        if (i) res ~= ", ";
        res ~= key ~ " " ~ val;
    }

    assert(res == "foo 1, bar 2");
}

A map + joiner call would suffice here of course.

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

Reply via email to