zip + assocArray problem

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 27 15:25:57 PST 2014


The line where aa2 is initialized gets accepted, while the 
initialization of aa5 gets refused, despite in both cases they 
use zipped keys/values from immutable associative arrays:


import std.array: assocArray;
import std.range: zip;
immutable string[const string] aa1, aa2, aa4, aa5;
static this() pure {
     immutable aa3 = ["a":"b"];
     aa2 = aa3.byValue.zip(aa3.byKey).assocArray; // OK
     aa4 = ["a":"b"];
     aa5 = aa4.byValue.zip(aa4.byKey).assocArray; // Error
}
void main() {}


I am missing something or is something wrong?

Bye and thank you,
bearophile


More information about the Digitalmars-d-learn mailing list