On 2010-12-19 20:33, Nick Sabalausky wrote:
"retard"<r...@tard.com.invalid>  wrote in message
news:iejab1$2t...@digitalmars.com...

As you can see, most of the verbosity comes from the fact that lambdas in
D and C++ contain statements, not a single expression. It's like if-then-
else vs ternary ?:  -- In languages like Scala these are the same built-in
feature.

FWIW, I've always found "if() else" and other such constructs to be a bit
verbose to use inside an expression. So I've always liked ?:  (But I can
certainly see the advantages of being able to use statements as
expressions.)

There are other places where they can be useful, like initializing variables:

auto y = if (x == 3)
            4;
         else
            5;

In this simple case the ternary operator would of course be better to use.

--
/Jacob Carlborg

Reply via email to