From: Su Zhang Date: 2011-01-09T02:15:08+09:00 Subject: Re: Is singleton class of an object already created? I just found that even though a singleton method is removed, the receiver is still considered a singleton and cannot be dumped. --------------- foo = Object.new def foo.bar 'foo.bar' end p foo.singleton_methods # => [:bar] class << foo undef bar end p foo.singleton_methods # => [] Marshal.dump(foo) # error -------------- Looking inside marhsal.c, the following check routine is found: if (RCLASS_M_TBL(klass)->num_entries || (RCLASS_IV_TBL(klass) && RCLASS_IV_TBL(klass)->num_entries > 1)) { rb_raise(rb_eTypeError, "singleton can't be dumped"); } It seems that the records remains in some dispatch table even if Object#singleton_methods returns an empty array. -- Posted via http://www.ruby-forum.com/.