Replies: 1 comment
-
|
Ruby does have negative integer literals, which is more intuitive in my opinion. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Ruby appers to take rather unique approach to parsing numeric literals, by allowing sign to be a part of the literal, unless it's separated by a whitespace:
Whereas in e.g. C++:
or in Python:
I could not find any documentation regarding this (the official documentation only contains non-negative numbers as examples), and I'm curious about the rationale behind such design.
I'm mainly wondering which approach I should be taking in my own toy language. I think I like Ruby's way better, but I'd like to know possible pros and cons I may be missing.
Beta Was this translation helpful? Give feedback.
All reactions