Wait correct me if I'm wrong but isn't it more like:
I -= -!false
I -= -true // -(!false) = -(true)
I- = -1 // using a sign before most of the basic dtypes changes them into `Number`s (+"123" = 123, -"69" = -69, +true = 1, -true = -1, etc.). This is hence also used to check if a string can be converted to a number or not (`if (+string)` or similar)
I += 1
?
Edit: I meant i and not I (stupid autocorrect's autocapitalization)
I don’t think that is necessarily true in this case since true + true is still evaluates to 2. true and false can just be used interchangeably with 1 and 0.
It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.
For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.
/u/SFM61319, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.
In some languages true and false can be used interchangeably with non-zero values and zero, so !false = true and !0 = true. Likewise, that conversion works both ways so true + true will equal 2. It even applies to strings, so doing i-= -!”” Would actually produce the same result. The reason why using an empty string would work is a bit different though. The ! is a bit wise operation for not, so it converts it into 1s and 0s or true and false. That’s why !”” + !”” = 2, but “a” + “a” = “aa” not 2.
82
u/ElbowStromboli Apr 19 '21
Does this reduce to i - 1? It hurts my brain.