Is there an elegant way of making a Result eager instead of lazy?

Ali Çehreli acehreli at yahoo.com
Tue Mar 20 14:52:05 PDT 2012


On 03/20/2012 10:50 AM, bearophile wrote:
 > simendsjo:
 >
 >> std.array includes a method, array(), for doing exactly this:
 >> int[] test2 = array(map!"a+a"(test1)); //eager
 >
 > With 2.059 you can write that also in a more readable way, because 
there is less nesting:
 >
 > int[] test2 = test1.map!q{a + a}().array();

Going off-topic but there is also the new => lambda syntax:

     int[] test2 = test1.map!(a => a + a)(test1).array();

Although, it makes it longer in cases like the one above. :)

By the way, is there a name for "the => syntax"?

 >
 > Bye,
 > bearophile

Ali



More information about the Digitalmars-d-learn mailing list