O'Reilly logo

Ruby Quick Syntax Reference by Matt Clements

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 6

image

Numbers

The Numeric class within Ruby is a containing class for the Integer and Float classes. This contains all methods linked to numeric variables either with (float) or without (integer) decimal places. The Numeric class is a very simple class, which holds the ability to perform a number of complex calculations with numbers.

Creating Numbers

Creating a number in Ruby is extremely simple, rather like creating a String. Rather than using a New method, or a set of braces, like an array or hash, a Number is created by setting a variable without quotation marks. If the number contains a decimal place, it is created as a float; if the number ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required