Ruby For Rails class_eval question

When I run the following example on page 349, I get the error message:

NoMethodError: undefined method `some_method' for #<C:0x2e3d698 @x=1>         from (irb):94         from &#9829;:0

c = Class.new c.class_eval do def some_method puts "Created in class_eval" end end c = C.new c.some_method

How to run this example? I followed the suggestion on the Manning's errata page with no luck. TIA.

Hi --

When I run the following example on page 349, I get the error message:

NoMethodError: undefined method `some_method' for #<C:0x2e3d698 @x=1>        from (irb):94        from ?:0

c = Class.new c.class_eval do def some_method puts "Created in class_eval" end c = C.new c.some_method

How to run this example? I followed the suggestion on the Manning's errata page with no luck. TIA.

The erratum has an erratum.... The two lines I provided are run together into one. They should be split, as below.

The whole thing should be:

   c = Class.new    c.class_eval do      def some_method        puts "Created in class_eval"      end    end

   c_instance = c.new    c_instance.some_method

David