I have a Ruby code as shown below, Try it online!
loop{p$.+=1r}
and another one, in which I just divide the 1r
by 2 as shown below, Try it online!
loop{p$.+=1r/2}
As far as I can guess, the type-casting isn't working properly with $.
. In the first case, it works correctly, but in the second one, it doesn't. strange!
So, why it works that way? Or, maybe my guess is wrong, then what is the actual issue, and how to resolve it?
Usually, Integer
are up-casted to more complex data types, like in this code, it seems to work.