damonh damonh - 9 months ago 48
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?


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.