Difference between 4 % 2 and 4 %2
-
Does anyone know why 4 %(space)2 works, but 4 %(no space)2 raises a syntax error (if it's in a file)?
Also, why does 2 -1 work, and 2.to_f - 1 works, but 2.to_f -1 doesn't?
-
Id guess its to do with how ruby expects to receive arguments for the method. If you put brackets around it it should work, i.e.
4%(2)
and2.to_f-(1)
Advertisement