From: "David A. Black" Date: 2007-10-26T03:59:43+09:00 Subject: Re: Need help understanding metaclassing Hi -- On Fri, 26 Oct 2007, Robert Dober wrote: > Notwithstanding the answers you got already and they are very worthy > indeed I would like to add my grain of salt. > I like to see metaprogramming a little bit as program generation > > A.module_eval { s/{/do/ :-) > define_method :b do |n| 42*n end > end > > is just the same as the following of course > class A > def b n > 42*n > end > end It's very key, though, that define_method takes a block, since that gives the method body access to local variables. David -- Upcoming training by David A. Black/Ruby Power and Light, LLC: * Advancing With Rails, Edison, NJ, November 6-9 * Advancing With Rails, Berlin, Germany, November 19-22 * Intro to Rails, London, UK, December 3-6 (by Skills Matter) See http://www.rubypal.com for details!