Chapter 5. Number Utilities

image with no caption

Numbers are fundamental for all computers and programming languages, and Ruby is no exception. In this chapter’s scripts, we’ll deal with useful data that is primarily numeric but is otherwise quite diverse. We’ll explore some pure math, following up with recursion, which I introduced in Chapter 4. We’ll also do some type conversion, whereby numbers will be represented in different ways that are convenient for human users. We’ll also do some unit conversion, specifically monetary units.[12] While doing all of this, we’ll also delve further into metaprogramming, Hashes, using external libraries, and two distinct formats ...

Get Ruby by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.