Setting a list of values

Xinok via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 1 12:54:48 PDT 2016


On Sunday, 1 May 2016 at 05:42:00 UTC, Ali Çehreli wrote:
> On 04/30/2016 10:05 PM, Joel wrote:
> > This has no effect:
> > _bars.each!(a => { a._plots.fillColor = Color(255, 180, 0);
> });
>
> This is a common issue especially for people who know lambdas 
> from other languages. :)
>
> Your lambda does not do any work. Rather, your lambda returns 
> another lambda, which is promptly ignored:

Those are some discrete semantics. I know D pretty well and even 
I didn't see the problem initially. Anybody else think it's worth 
adding a warning to the compiler for this specific case? If this 
is the user's intended behavior, then they can rewrite it like 
this to be explicit and disable the warning:

_bars.each!(a => (){ a._plots.fillColor = Color(255, 180, 0); });
//               ^^ add empty parenthesis before the curly brace


More information about the Digitalmars-d-learn mailing list