CHAPTER 16

image

Metaprogramming

Metaprogramming is the ability to write code that operates on other code, rather than data. In all previous chapters we have written code that operates on other data, such as the reading/writing of variables, outputting to screen, communicating with files or other input output streams. Metaprogramming is the ability to write code that adjusts the functionality of a class or dynamically call a method without a direct call to this method existing within the executable code. This is extremely useful when you want to amend the method being called depending on a scenario, or if you want to modify the behavior of a class during ...

Get Ruby Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.