Few recent dmd pull requests

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 26 07:45:05 PDT 2014


H. S. Teoh:

> What's wrong with just writing auto?
>
> 	auto sqr = a => a^^2;
> 	auto r = [1,2,3].map!sqr;

auto is used to use the type of the value on the right. But "a => 
a^^2" is not a value, it can't be assigned to a variable, because 
it's not a lambda.

To use auto you need to give a type, creating a lambda:

auto sqr = (int a) => a ^^ 2;

Bye,
bearophile


More information about the Digitalmars-d mailing list