A lot of ruby's syntax and parsing is relatively logical, but I am confused as to how ruby knows, from context, that
2 /3/ 4 is 2 ÷ 3 ÷ 4 instead of parsing
/3/ as a regex? It's a correct parsing, but
/3/ is also a valid regex, and how would it know that
/3/ is not a regex.
I thought that this might be a numeric literal thing, but if you do
a = 6 b = 4 c = 2 a /b/ c
Ruby still parses this as division. How does this work?
Actually, I realized there is more to this question,
let's say I have this
def a(x) x end a = 4 b = 2 i = 4 a /b/i #=> 0
a /b/i parsed as
0 instead of
as in why does
a /b/i get parsed as
a./(b./(i)) instead of