Skip to Content
Metaprogramming Ruby 2
book

Metaprogramming Ruby 2

by Paolo Perrotta
August 2014
Intermediate to advanced
250 pages
6h 20m
English
Pragmatic Bookshelf
Content preview from Metaprogramming Ruby 2

Quiz: Missing Lines

Where you find your way around the Ruby object model.

Back in The Truth About Classes, Bill showed you how objects and classes are related. As an example, he used a snippet of code and this whiteboard diagram:

images/chp1_classes_1.jpg
 class​ MyClass; ​end
 obj1 = MyClass.new
 obj2 = MyClass.new

The diagram shows some of the connections between the program entities. Now it’s your turn to add more lines and boxes to the diagram and answer these questions:

  • What’s the class of Object?
  • What’s the superclass of Module?
  • What’s the class of Class?
  • Imagine that you execute this code:
     obj3 = MyClass.new
     obj3.instance_variable_set(​"@x"​, 10) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Ruby Programming Language

The Ruby Programming Language

David Flanagan, Yukihiro Matsumoto
Head First Ruby

Head First Ruby

Jay McGavren
Eloquent Ruby

Eloquent Ruby

Russ Olsen

Publisher Resources

ISBN: 9781941222751Errata Page