3 ms·
Why was he surprised that it works? -1 is a perfectly normal integer and -= is a perfectly valid operator.
by metalliqaz 7y ago
Why was he surprised that it works? -1 is a perfectly normal integer and -= is a perfectly valid operator.
- ImpressiveWebs 7y agoHe wasn’t surprised it worked, he was surprised someone used it. At least that’s how I took it.
- seasoup 7y agoI think that while people wouldnt be surprised that i -= -1 works, formatted as i-=-1 it's unclear what each - is doing, likely someone did it because it looks nice and symmetrical, as opposed to i+=1
- supereggbert 7y agoProbably because in js if i="1" then i+=1 results in i="11" but i-=-1 results in i=2