May 2022
Beginner
352 pages
7h 5m
English
Now that we’ve taken a look at strings and arrays, we’ll continue with a tour of some other important Ruby objects: math, dates, regular expressions, and hashes.
Like most programming languages, Ruby supports a large number of mathematical operations:
Be especially careful with division, though; it can be counter-intuitive:
Here Ruby uses integer division, which returns the number of times the denominator goes into the numerator. When dividing one number by another, chances are you want floating-point division instead, which you can get by adding a “point zero” to at least one of the numbers:
Read now
Unlock full access