Make a hash out of two ranges
Jonathan M Davis
jmdavisProg at gmx.com
Wed Feb 27 20:13:04 PST 2013
On Thursday, February 28, 2013 04:56:48 Andrej Mitrovic wrote:
> import std.algorithm;
> import std.range;
>
> void main()
> {
> auto r = map!((a, b) => [a : b])(["foo"], ["bar"]); // error
> assert(r.front == ["foo" : "bar"]);
> }
>
> This doesn't compile, what am I missing?
Map only works on one range. You can't pass it two of them at the same time.
You'd need to wrap them in a single range of pairs with something like zip.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list