damonh damonh - 1 year ago 64
Ruby Question

How is a negative number parsed in Ruby?


, is
parsed as part of the literal as a sign, or an operator to turn the value into its negative counterpart?

Answer Source

It is parsed as part of the literal, and makes the literal a negate literal.

Here's the reference in the parser source code. If you search the file for tUMINUS_NUM and tUMINUS you'll see where the - token is defined.