I'm reading the Ruby for Rails book, and on page 350 it has the example irb(main):001:0> var = "initialized variable" => "initialized variable" irb(main):002:0> class C; end => nil irb(main):003:0> C.class_eval { define_method("talk") { puts var } } => #<Proc:0x00355c30@(irb):3> irb(main):004:0> C.new.talk initialized variable => nil So I wanted to see if I could do that within the class. I've tried the following approach: irb(main):005:0> class A irb(main):006:1> class_eval { define_method("talk") { puts var } } irb(main):007:1> end => #<Proc:0x0033f0ac@(irb):6> irb(main):008:0> A.new.talk NameError: undefined local variable or method `var' for #<A:0x337c30> from (irb):6:in `talk' from (irb):8 from :0 I've also tried it with self.class_eval within the class definition. Can someone explain to me what the difference is between the inline code example, and specifying it inside the class? Obviously they're not equivalent, otherwise my attempt would work...I just don't understand what the difference is. Pat