3 ms·
For any struggling to understand Ruby's metaprogramming, the rather short and succinct Metaprogramming Ruby is an excellent read. There's a method to the madnes
by vinceguidry 12y ago
For any struggling to understand Ruby's metaprogramming, the rather short and succinct Metaprogramming Ruby is an excellent read. There's a method to the madness of define_method, method_missing, the various eval methods, the difference between Blocks, Procs, and Lambdas. Most of it revolves around manipulating scopes.
It also shows how you can iterate from the ugliest, most powerful, most dangerous eval method by pulling out the functionality you need into less-powerful, safer manipulations. It's all Ruby code until it's actually executed, so it can all be manipulated at runtime.
http://www.amazon.com/Metaprogramming-Ruby-Program-Like-Pros/dp/1934356476 http://www.amazon.com/Metaprogramming-Ruby-Program-Like-Pros...
- tcopeland 12y agoYup this is great stuff, just be sure to get the 2nd edition which just came out: http://www.amazon.com/Metaprogramming-Ruby-Program-Like-Facets/dp/1941222129/ref=dp_ob_title_bk http://www.amazon.com/Metaprogramming-Ruby-Program-Like-Face... It focuses on modern Rubies, so it talks about Module#prepend and such. Nice to keep moving forwards.
- thirdtruck 12y agoSeconding. The book revolutionized my understanding of Ruby, and inspired me to create a whole visual novel framework: https://github.com/thirdtruck/rubyai https://github.com/thirdtruck/rubyai.