Simplest way to create an array from an associative array which its contains keys and values?
Andrej Mitrovic
andrej.mitrovich at gmail.com
Fri Jan 3 09:49:28 PST 2014
On Friday, 3 January 2014 at 17:38:16 UTC, Gary Willoughby wrote:
> I know it can be done via a loop, but is there a more idiomatic
> way to achieve this?
----
import std.algorithm;
import std.range;
import std.stdio;
void main()
{
auto aa = ["one":"1", "two":"2"];
auto range = aa.byKey.map!(a => chain(a.only, aa[a].only));
string[] array = range.join;
writeln(array);
}
----
However I'm not sure whether "only" is present in 2.064, maybe it
was added recently in the git-head version.
More information about the Digitalmars-d-learn
mailing list