From: Christoph Date: 2005-05-01T12:15:27+09:00 Subject: Re: instantiating metaclasses, sorta [Was: determining when inside 'class << self'] Jim Freeze schrieb: > I'm not sure I understand your point here. > >A typical use is below: > > irb(main):001:0> module M > irb(main):002:1> def fred; "fred"; end > irb(main):003:1> end > => nil > irb(main):004:0> class C; end > => nil > irb(main):005:0> c = C.new > => # > irb(main):006:0> c.extend M > => # > irb(main):007:0> c.fred > => "fred" > irb(main):008:0> c = c.dup > => # > irb(main):009:0> c.fred > NoMethodError: undefined method `fred' for # > from (irb):9 > from :0 > >But, if you have module methods and extended an object, >what would be the point? How do module methods show up >in extended objects? I thought they didn't. > > Cloning a Module object and cloning an object that was extend by Module is very different and cloning a Class object is jet another subject - speaking of which The following abuse creates an unprintable Class object --- class O end P = class << O; self end.dup class << P p superclass rescue SystemStackError => mes puts mes # stack level too deep end --- /Christoph