
Saved by Harold T. Harper
The Well-Grounded Rubyist
Saved by Harold T. Harper
The top-level namespaces are modules. By default, your app is a module and hence a namespace; that namespace’s name is, roughly speaking, the name of the app.
Except we’ll talk about the vertical-bar-thingies, like in |lang|. It looks weird, but the idea is simple: lang is the variable that each will use to point to the objects in the array. How would you otherwise refer to the string "English"? (Well, maybe using languages[0], but the entire point here was to avoid messing with the slot number
... See moreFirst, new is a method of the class, while initialize is a method of the instance. You call new to create the instance, and then initialize is automatically called on that instance. This means that the call to new must come first. Until you call new, there’s no instance to call initialize upon.
We try to think about objects in terms of roles, responsibilities, and collaborators, as best described by Wirfs-Brock and McKean in [Wirfs-Brock03]. An object is an implementation of one or more roles; a role is a set of related responsibilities; and a responsibility is an obligation to perform a task or know information. A collaboration is an int
... See more