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 ...

Get Ruby Quick Syntax Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.