Simplest way to create an array from an associative array which its contains keys and values?

Justin Whear justin at economicmodeling.com
Fri Jan 3 09:55:56 PST 2014


On Fri, 03 Jan 2014 17:49:28 +0000, Andrej Mitrovic wrote:

> 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.

`only` is available in 2.063, maybe even earlier.


More information about the Digitalmars-d-learn mailing list