"Paul Brannan" <pbrannan / atdesk.com> wrote in message news:20020919172550.F6781 / atdesk.com...
> On Fri, Sep 20, 2002 at 05:41:58AM +0900, Christoph wrote:
> > Beast = self
> > (@temptation = Class.new String).class_eval <<-Body
> > Beast = self
> > def six_six_six; Beast end
> > Body
>
> What's wrong with:
>
>   Beast = self
>   (@temptation = Class.new String).class_eval do
>     Beast = self
>     def six_six_six; Beast end
>   end

(In 1.7 one can also use Class.new super_class  { .. }  )

``proc type'' class_eval's  do not change the scope. In other
words there is only one (the top) Beast around - hence

 p six_six_six  # =>
 #<Object:0x1011b550 @temptation=#<Class:0x1010a7f8>>

A ``string type'' class_eval creates the expected two
Beasts and six_sx_six picks up the inner Beast - hence

p  six_six_six  # =>
#<Class:0x1010c388>

/Christoph