"Bertram Scharpf" <lists / bertram-scharpf.de> schrieb im Newsbeitrag
news:20050111144155.GA19812 / homer.bertram-scharpf...
> Hi,
>
> I try to understand more deeply what Ruby does.
> Why here is the first line forbidden, the second allowed?
>
>     def f ; class C ; end ; end

This is a syntax error.  The construct "class ... end" is simply
syntactically not allowed in a method.  IMHO it doesn't make much sense
also, but that's another story.

>     def f ; eval "class C ; end", binding ; end

Well eval "..." is just an expression and "eval" evaluates everyhing it
get's that's syntactically correct.  The ruby code in the string
expression is not syntactically located in method f.  It's parsed at
runtime while the line above is completely evaluated at compile time.

HTH

    robert


> Thanks for your answers in advance.
>
> Bertram
>
> -- 
> Bertram Scharpf
> Stuttgart, Deutschland/Germany
> http://www.bertram-scharpf.de
>
>