You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The null-coalescing assignment operator ??= assigns the value of its right-hand operand to its left-hand operand only if the left-hand operand evaluates to null. The ??= operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-null.
Note for the implementation: this should not array-read twice, so we need a temp var and turn it into { var tmp = arr[x]; tmp != null ? tmp : arr[x] = []; }.
This might make it worthwhile to have a distinct block-level case where it simply becomes if (arr[x] == null) arr[x] = [].
The following code:
Produces the following result:
I would expect instead it to be:
arr[x] != null ? arr[x] : arr[x] = []
So no assign is performed if not null.
The text was updated successfully, but these errors were encountered: