At the recommendation of Joe O’Brien, I watched Dave Thomas’ fantastic bottom-up explanation of Metaprogramming in Ruby.
The talk provides a very lucid explanation of a lot of Ruby (and Rails) magic that always gets glossed over in any intro to ruby kind of talk. It’s kind of the same way I never really *got* certain concepts until I made my 9th grade teacher completely show me Proof By Induction.
Anyway, I highly recommend it for any computer-science curious types.
It crescendos to wonderful payoff where this piece of code makes complete sense:
class Class
def meta
class << self
self
end
end
end
class Dave
class << self
def self.hi
puts "WHATS UP META!"
end
end
end
Dave.meta.hi
Related posts:
0 Comments
Leave Comment