From: nobu.nokada@... Date: 2002-02-20T03:35:41+09:00 Subject: Re: Anonymous class support Hi, At Wed, 20 Feb 2002 02:21:52 +0900, Christoph wrote: > > Class.new(superclass).class_eval do > > def foo > > end > > end > > > > In 1.7, .class_eval isn't necessary. > > Unfortunately you cannot use the ladder idiom within method bodies - for > example .. > > ---- > class A > def foo(&body) > Class.new(type,&body) > end > def goo(&body) > res = Class.new(type) > res.class_eval &body # this works because &body is a string! > res > end > # > end > > > anon =A.new.foo { Pointless = "okay" } > puts anon.const_get :Pointless # => okay > # A.new.foo { def annoying_parse_error() end } > > anon.new.goo { def okay(); puts "okay" end }.new.okay # => okay Well, aboves worked all without any errors on my box. Both of 1.6.6 and 1.7.2, 2002-02-19. What version do you use? -- Nobu Nakada