[Issue 9868] New: Hash iteration should support counter variable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Apr 3 12:10:59 PDT 2013
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: nobody at puremagic.com
ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 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: -------
More information about the Digitalmars-d-bugs
mailing list