On 4/4/07, Hugh Sasse <hgs / dmu.ac.uk> wrote: > Also makes me think: what about non-anonymous singleton classes? > > irb(main):002:0> class X << x > irb(main):003:1> def hello > irb(main):004:2> puts "hi" > irb(main):005:2> end > irb(main):006:1> end > SyntaxError: compile error > (irb):2: syntax error, unexpected tLSHFT, expecting '<' or '\n' or ';' > class X << x > ^ > from (irb):6 > from :0 > irb(main):007:0> > > Fair enough! :-) That would produce some weird prototype based OO > if it were allowed, though. Not too far off already though: Proto = Class.new(Class) def Proto.clone; Class.new(self) end A = Proto.clone def A.test puts 42 end A.test #=> 42 class << A def almost puts :there end end A.almost #=> :there So ideally we might have: class A << Proto.clone ... end Interesting thought, though I wonder how much longer Class.new(Class) will work since class Proto < Class doesn't work. Brian.