
Saved by Harold T. Harper
Learn to Program
Saved by Harold T. Harper
The main thing that changes from one local scope to another is your supply of local variables. When you leave a local scope—by returning from a method call, or by doing something that triggers a new local scope—you get a new supply. Even if you’ve assigned to a local variable x in one scope, you can assign to a new x in a new scope, and the two x’s
... See moreGlobal variables are recognizable by their leading dollar sign ($)—for example, $population.
The other sense in which it’s possible to “change” a constant is by making changes to the object to which the constant refers. For example, adding a venue to the Ticket class’s venue list is easy: Ticket::VENUES << "High School Gym" 1 1 Uses << to add new element to an existing array There’s no warning, because there’s no rede
... See moreAll Ruby objects are created with certain innate abilities—certain methods that they know how to execute because they’re Ruby objects. Those abilities, although important, aren’t that exciting, so we’ll keep them to the side for the moment. More exciting is what happens when you teach your object how to do the things you want it to do.