I forget where I originally found this and Google on my phone was unhelpful.
My favorite annoying trick is x -=- 1. It looks like it shouldn’t work because that’s not precisely a valid operator, but it functions as an increment equivalent to x += 1
It works because -= still functions are “subtract and assign”, but the second minus applies to the 1 making it -1.
I forget where I originally found this and Google on my phone was unhelpful.
My favorite annoying trick is
x -=- 1
. It looks like it shouldn’t work because that’s not precisely a valid operator, but it functions as an increment equivalent tox += 1
It works because
-=
still functions are “subtract and assign”, but the second minus applies to the 1 making it -1.