Lazy Literal Range: Stooid late-nite idea?

Vladimir Panteleev vladimir at thecybershadow.net
Sat Oct 8 23:33:11 PDT 2011


On Sun, 09 Oct 2011 06:06:21 +0300, Nick Sabalausky <a at a.a> wrote:

> Great, right? But what about this?:
>
>     auto x = [runtimeExpressionA, runtimeExprB, runtimeExprC,
> etc].find(blah);

With the anonymous delegate literal syntax suggested by Andrei a while  
ago, you should be able to write this as:

auto x = [() => runtimeExpressionA, () => runtimeExprB, () =>  
runtimeExprC, () => etc].find(blah);

I guess it looks quirky with an empty parameter list, but it's shorter  
than writing {return runtimeExpressionA;}, {return runtimeExpressionB;}  
etc.

-- 
Best regards,
  Vladimir                            mailto:vladimir at thecybershadow.net


More information about the Digitalmars-d mailing list