Adding the ?. operator to D
FeepingCreature
feepingcreature at gmail.com
Thu Sep 17 07:06:24 UTC 2020
On Wednesday, 16 September 2020 at 19:01:28 UTC, Jacob Carlborg
wrote:
>
> I would like that. It should work for an Optional/Nullable type
> as well. It's a good idea to add an `??` operator at the same
> time as well:
>
> auto a = A ?? B;
>
> if `A` is not null, assign `A` to `a`. Otherwise assign `B` to
> `a`.
This is also known as "||". :-)
It only requires the change that || return the merged truthy type
of its parameters rather than bool. For instance, for objects 'a
|| b' would merge to the most derived superclass of a and b.
More information about the Digitalmars-d
mailing list