From: Robert Klemme Date: 2011-01-05T17:21:43+09:00 Subject: Re: Is singleton class of an object already created? On Wed, Jan 5, 2011 at 2:36 AM, Samnang Chhun wrote: > I'm not sure every time we invoke 'singleton_methods', then it will > create the singleton class if it doesn't exist yet. Apparently it doesn't according to Brian's test: irb(main):001:0> x="foo" => "foo" irb(main):002:0> Marshal.dump(x) => "\x04\bI\"\bfoo\x06:\rencoding\"\nCP850" irb(main):003:0> x.singleton_methods => [] irb(main):004:0> Marshal.dump(x) => "\x04\bI\"\bfoo\x06:\rencoding\"\nCP850" irb(main):005:0> def x.a;end => nil irb(main):006:0> Marshal.dump(x) TypeError: singleton can't be dumped from (irb):6:in `dump' from (irb):6 from /opt/bin/irb19:12:in `
' irb(main):007:0> Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/