Sam Smoot
1/22/2006 2:30:00 AM
Is there any difference between these?
def test1()
msg = 'bar'
self.class.class_eval do
define_method('foo') { msg }
end
end
def test2
msg = 'baz'
(class << self; self; end).class_eval do
define_method('foo') { msg }
end
end
test1
puts foo
test2
puts foo
As far as I can tell, no?
If that's the case, is there any reason the second form seems so much
more common?