Working with Numbers
Learn about the different types of numbers in Ruby.
Numbers
We can create a number by simply writing it out. The number 123
is Ruby code, representing the number 123. We can also use a . as a decimal point, for example, 12.34.
Negative numbers are created by prepending a minus sign (-
). For example, -99
is the number -99.
We can also use an underscore (_) to improve readability when dealing with large numbers. For example, ...