I am trying to understand this line of code. What is the minus and tilde doing to r[e]?:
r = {}
for (e of s)
r[e] = -~r[e] // What is this specific line assigning?
for (e in r)
if (r[e] == 1)
return e
return '_'
The problem this code solves is this(specific line is commented):
Given a string s, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'.
I understand the other lines except the commented one.
for (e in r)iterates properties in order of their creation.