June 2007
Intermediate to advanced
294 pages
8h 6m
English
This script demonstrates basic Object Orientation by singing (okay, printing) the “99 Bottles of Beer” song. The content of the example may be a bit contrived, but the program itself reveals a great deal about naming conventions in Ruby. We’ll be defining a Wall, on which there are bottles, the number of which repeatedly drops by one.
Here’s the code. Classes are the basic building blocks in Ruby, so it’s worthwhile for anyone curious about the language to understand them in some depth. We’ve already seen some built-in classes (String, Integer, and Array), so they’re not a fundamentally new concept for you at this point. What is new is the ability to define completely novel classes of your own, as we ...
Read now
Unlock full access