Why is std.algorithm so complicated to use?

Ali Çehreli acehreli at yahoo.com
Mon Jul 9 13:23:34 PDT 2012


On 07/09/2012 01:16 PM, Andrei Alexandrescu wrote:
 > On 7/9/12 4:09 PM, Jacob Carlborg wrote:

 >> auto str = ["foo", "bar"].map!(x => x);
 >> auto f = str.sort();
 >>
 >> Results in:
 >>
 >> http://pastebin.com/BeePWQk9
 >
 > The first error message is at clear as it goes:
 >
 > Error: r[i2] is not an lvalue

And a quick fix is to make an array first:

     auto str = ["foo", "bar"].map!(x => x)().array();

Also note the added () for map, which is needed when compiled with 
-property.

Ali



More information about the Digitalmars-d mailing list