Express a[i]+-~j as a[i]-~j?
Closed this issue · 2 comments
Vogtinator commented
I'm wondering why a[i]-~j
isn't used instead of a[i]+-~j
.
It's that obvious that I'm probably missing something, but what?
xem commented
Hello! :)
It's not a real substraction.
Try to execute that in your JS console:
a="ABCD";for(j in a)for(i in a)console.log((y=a[i]+-~j) + " vs " + (y=a[i]-~j))
you'll get:
A1 vs NaN
B1 vs NaN
C1 vs NaN
D1 vs NaN
A2 vs NaN
B2 vs NaN
C2 vs NaN
D2 vs NaN
A3 vs NaN
B3 vs NaN
C3 vs NaN
D3 vs NaN
A4 vs NaN
B4 vs NaN
C4 vs NaN
D4 vs NaN
you should see this expression as a concatenation of the string a[i], and -~j
which is a shorter way to write (j+1)
Vogtinator commented
Ok, so it's actually string concatenation.
Thanks for the explanation!