ID:2571455
 
Resolved
||= and &&= shortcut operators have been added.
Applies to:DM Language
Status: Resolved (514.1543)

This issue has been resolved.
(Couldn't find an existing request, but I remember this being brought up before)

New operator:
a ||= b
// equivalent to
a = a || b

Saves typing the left side twice.
Also only evaluates the right hand when necessary.

Should also support these usages:
a[b] ||= c

var/type/a
a ||= new

See how other languages do it:
C#
PHP
+1, ALL THE LOGIC /o/
Yeah, this has kinda been on my mind a while as well. Consider it on the list for 514.
This is implemented for BYOND 514. The issue will be closed when the first beta is released.

The way this operator works is that the LHS is evaluated only once, so if it's a complex expression like L[i++] then the increment to i only happens once and you'll still be at the same list index if an assignment happens.

The RHS is only evaluated if the LHS is true or false, depending on which operator you use. That is, for the ||= operator the RHS is ignored if the LHS is true; for the &&= operator the RHS is ignored if the LHS is false.
Lummox JR resolved issue with message:
||= and &&= shortcut operators have been added.