Class Definitions Demystified
Where you and Bill tread familiar ground: the Bookworm application and the Ruby object model.
You stumble sleepily into the office, craving your Thursday morning coffee, only to be ambushed by an excited Bill. “Hey!” he says. “Everyone likes the refactorings of Bookworm we did Monday, and the boss wants more. But before we start, let’s go over some theory about class definitions. We’ll begin where we left off Monday: in the Ruby object model.”
Inside Class Definitions
You probably think of a class definition as the place where you define methods. In fact, you can put any code you want in a class definition:
| class MyClass |
| puts 'Hello' |
| end |
<= | Hello |
Class definitions also return the value of the last ...
Get Metaprogramming Ruby 2 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.