On Saturday, 28 October 2017 at 11:38:52 UTC, Andrei Alexandrescu wrote:
Walter and I decided to kick-off project Elvis for adding the homonym operator to D.

I'd like to mention null-coalescing assignment syntax. Perl has `$a //= $b`, and PHP has voted to support `$a ??= $b`, expanding to `$a = $a ?? $b`. Rationale:

// The following lines are doing the same
$this->request->data['comments']['user_id'] = $this->request->data['comments']['user_id'] ?? 'value'; // Instead of repeating variables with long names, the equal coalesce operator is used
$this->request->data['comments']['user_id'] ??= 'value';

https://wiki.php.net/rfc/null_coalesce_equal_operator

I expect D could do the same with `a ?:= b` or use the `??` operator syntax.

Just from memory, I think I would use null coalescing assignments more than null coalescing comparisons.

Reply via email to