Closed foremtehan closed 3 hours ago
This won't generalise well.
The reason .=
exists is because all other binary operators can be used in compound form as well, e.g. +=
, -=
, ... so it makes sense to have .=
too.
However, =+
and =-
would be ambiguous, consider this: $a =- 3
. Does this means "set $a to -3" or "subtract 3 from $a".
It would be inconsistent to have =.
as an exception.
Description
I was wondering, why don’t we have an operator that performs the opposite of the concatenating assignment operator .=? This new operator could prepend a value:
What's the problem with this?