-
Book Overview & Buying
-
Table Of Contents
Polished Ruby Programming - Second Edition
By :
Ruby has multiple numeric types, such as integers, floats, rationals, complex numbers, and BigDecimals, with integers being the simplest type. As a general principle when programming, you should attempt keep your design simple, and avoid adding complexity unless the benefits outweigh the costs. Applying the principle to Ruby, if you need to choose a numeric type then you should generally use an integer, unless you need to deal with fractional or complex numbers.
Note that while this chapter is supposed to discuss core classes, BigDecimal is not a core class, though it is commonly used. BigDecimal ships with Ruby as one of the bundled gems, and you need to require bigdecimal before using it.
Integers are the simplest numeric type, but they are surprisingly powerful in Ruby, compared to many other programming languages. One example of this is executing a block of code a certain number of times. In many other languages, this is either done with...
Change the font size
Change margin width
Change background colour