Why Ruby?

Jacob Carlborg doob at me.com
Sun Dec 19 12:16:36 PST 2010


On 2010-12-19 20:33, Nick Sabalausky wrote:
> "retard"<re at tard.com.invalid>  wrote in message
> news:iejab1$2t7$1 at 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


More information about the Digitalmars-d mailing list