Mark J. Reed
12/1/2003 3:22:00 PM
On Mon, Dec 01, 2003 at 03:20:16PM +0000, Asfand Yar Qazi wrote:
> Where's the "Attr"?!!!!!!
It's not there because the self.class call skips right over the
singleton class and returns the proper, named, original class:
irb(main):001:0> s="Hello"
=> "Hello"
irb(main):002:0> s.class
=> String
irb(main):003:0> class << s
irb(main):004:1> def greet(greetee="World")
irb(main):005:2> puts "#{self}, #{greetee}!"
irb(main):006:2> end
irb(main):007:1> end
=> nil
irb(main):008:0> s.class
=> String
And the original class doesn't have Attr included.
AFAIK there's no built-in method to get the singleton class of an object,
but someone just posted a pointer to code that does it over in the
"class << x" thread.
-Mark