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

Reflection

Ruby is a very permissive language, as you’ve already seen time and time again. It allows developers to open any class, add new methods, remove others, include mixins, and more. Ruby isn’t satisfied with just that, and so it provides some impressive reflection capabilities.

Reflection means that the code can investigate itself and its environment. Hence, you can retrieve a list of current defined variables, check what the superclass of an object is, and more. This gives you a lot of control over objects during the runtime of the application.


  

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