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
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 7. Classes and Modules > Singleton Methods and the Eigenclass

7.7. Singleton Methods and the Eigenclass

We learned in Chapter 6 that it is possible to define singleton methods—methods that are defined for only a single object rather than a class of objects. To define a singleton method sum on an object Point, we’d write:

def Point.sum
  # Method body goes here
end


  

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