damonh damonh - 1 year ago 106
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download