From: Daniel Waite Date: 2007-10-26T06:16:59+09:00 Subject: Re: Need help understanding metaclassing Chris Czub wrote: > Daniel Waite wrote: >> That's the same code as above. Still doesn't work though. =) > > Nope, it's c.eat instead of cs.eat... works for me! :) Hehe, I feel sheepish. (Yes, works for me, too.) So... what I gather then is that it's possible to, from the viewpoint of the singleton, duck back into the object that spawned it. Why you would do that I don't know, but it can be done. It looks like the only way to define a method on a singleton object is to use... cs.instance_eval do def eat puts "You eat." end end I find that restrictive because you can't dynamically create a method name. It looks likes you can extend it with modules: module Bounce def bounce puts "You bounce." end end cs.extend Bounce cs.bounce # You bounce. What is special about the singleton object such that it cannot be extended using define_method? -- Posted via http://www.ruby-forum.com/.