just an idea (!! operator)
Christophe Travert
travert at phare.normalesup.org
Thu Jul 12 05:26:09 PDT 2012
Christophe Travert, dans le message (digitalmars.D:172047), a écrit :
> "Jonas Drewsen" , dans le message (digitalmars.D:172039), a écrit :
>> On Wednesday, 11 July 2012 at 11:18:21 UTC, akaz wrote:
>>> if needed, the operator !! (double exclamation mark) could be
>>> defined.
>>>
>>> ...
>>
>> Or the operator?? could be borrowed from c#
>>
>> auto a = foo ?? new Foo();
>>
>> is short for:
>>
>> auto a = foo is null ? new Foo() : foo;
>
> or maybe:
> auto a = ! ! foo ? foo : new Foo();
I forgot to mention that foo would be evaluated only once (and the
second operand would be evaluated lazily). This is the main point of
this syntax, and it is not easily emulable (as long a lazy is not
fixed).
More information about the Digitalmars-d
mailing list