D with experimental features like tuple unpacking

Denis Shelomovskij verylonglogin.reg at gmail.com
Fri Mar 22 00:05:05 PDT 2013


22.03.2013 1:13, bearophile пишет:
> And in foreach:
>
> foreach ((c, ref e); loa)


D already have undocumented[1] front tuple expansion in foreach over range:
---
import std.algorithm;
import std.stdio;

void main() {
     enum s = "this is an example for huffman encoding"d;
     foreach (c, n; s.dup.sort().release().group())
         writefln("'%s'  %s", c, n);
}
---

[1] http://d.puremagic.com/issues/show_bug.cgi?id=7361

-- 
Денис В. Шеломовский
Denis V. Shelomovskij


More information about the Digitalmars-d mailing list