From: ara.t.howard@... Date: 2006-04-11T14:03:43+09:00 Subject: Re: Class Definition inside a method definition? On Tue, 11 Apr 2006, Bihal wrote: > Hey guys, > > Here's another one, only it's not a singelton > > def self.declare_dndclass(classname,registername) > str = <<"EEOOFF" > class #{classname} < DragDropRubyObject > FormatName = '#{registername}' > FormatId = RegisterClipboardFormat.call(FormatName) > end > EEOOFF > eval(str) > eval("#{classname} ") > end > > Any thoughts? > > Bihal i don't see a class definition - only some methods being called on 'self', which happens to be a class here. eg. self.eval str self.eval "#{ classname }" this method could have just have easily been written as def self.declare_dndclass cn, rn klass = Class.new(DragDropRubyObject) do FormatName = rn.to_s FormatId = RegisterClipboardFormat[FormatName] end const_set cn, klass const_get cn end and here this is also no class definition in the syntactical sense - only the creation of a class object and a const assignment. make sense? -a -- be kind whenever possible... it is always possible. - h.h. the 14th dali lama