Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Inheritance and More

8. Inheritance and More

Chapter 7, “Creating Classes,” walks through the fundamentals of defining and using your own classes. That chapter includes all of the basic syntax, how to use instance variables within the class, and how to define special methods and operators. In this chapter, the subject of OOP is taken one important step further: into the realm of inheritance. Inheritance is the act of deriving one class, called the child or subclass, from another, called the parent, superclass, or base class. The derived class will begin with the same properties as the base class, but those can then be expanded or altered as needed. Inheritance gives OOP its muscle, making it so much more useful.

The chapter begins with the basics of inheritance in Ruby. Subsequent sections cover overriding methods, chaining methods, and class methods. The other two primary topics address access control and class variables. And, of course, there’s lots of extra information to be found in the various sidebars and tips.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint