Florian Frank
9/11/2006 11:37:00 AM
Srdjan Marinovic wrote:
> I've got a following problem: when I do
>
> instance_eval do
> class T
> end
> end
This works because the context of the block is used to create T.
> (i'm doing this in irb, so self is main)
>
> everything is fine, I get a new class T.
> However when I do
>
> instance_eval "class T; end"
>
> I do not get a new class T. even though no errors were reported. Is
> there any particular reason for this?
T is nested into the singleton class of main, you could use
instance_eval "class ::T; end"
to create a top level class.
But I don't understand why you use instance_eval, why not just eval?
--
Florian Frank