> From: nosuzuki / e-mail.ne.jp [mailto:nosuzuki / e-mail.ne.jp]On Behalf Of
>
[...]
> Raja S.
[...]
> Let me say up front that I'm trying to clarify my understanding of how things
> are in Ruby.  So my views below are more a reflection of my current
> understanding rather than how things truly are in Ruby.
Hi,

you might find the following script useful ...
(#you returns the singleton class of an Object
and adds class function #me to it which returns 
the original object.
Note the formation of a singleton Objects of a 
non singleton object of  type class is quite 
different from the formation of an ordinary 
singleton object ...

[...]

Christoph

--------------
$ ruby sing_toy.rb
true
true
true
true
true
false
[A, Object]
[84003572, 84038960]
[Class, Class, Module, Object]
[84004136, 84038924, 84038936, 84038948, 84038960]
[A, Object]
[84004136, 84038924, 84038936, 84038948, 84038960]
[A, Object]
[84003572, 84038960]
"b global"
"surprised ?"
--------------
class Object
def  you
	@@me = self
	 ObjectSpace._id2ref \
	 ( 
	 class << self; 
	 	@me =  @@me
	 	def self.me
	 		@me
	 	end	
	 	id 
	 end 
	 )
end
private
@@me = Object
end

class Class
def superclasses
	res=[ ]
	tmp= curr = self
	res << curr = tmp  while tmp  = curr.superclass
	return res
end
def superclasses_id
	res=[ ]
	tmp= curr = self
	res << (curr = tmp).id  while tmp  = curr.superclass
	return res
end
end
--------------
require 'SingProb'

class A
@@global = "AGlobal"
Konst="me"
attr_accessor :x
def initialize
	@x = "no surprise"
end		
end
class B < A
end

a = A.new
aA = a.you



p aA.me.id == a.id
p  A.you.me.id == A.id
p aA < A
p B.you <  A.you
p B.new.you < A
p A.you < A || A < A.you # the only false statement


p aA.superclasses
p aA.superclasses_id
p A.you.superclasses
p B.you.superclasses_id
p B.superclasses
p B.you.superclasses_id
p B.superclasses
p B.superclasses_id

class Object
def toy
	class << self;
	def x
		"surprised ?"
	end	
	@@global = "ToyGlobal"
	def global
		@@gobal
	end
	def self.global
		@@global
	end	
	def global=(other)
	    @@global = other
	 end   
	def self.x
	       @x
	 end
	 def self.x=(other)
	    @x = other
	 end
	 	Konst="TOY"
	def konst
		Konst 
	end
	def self.konst
		"toy" 
	end 
	end
end
end


b = B.new
b.toy
bB = b.you
b.global= "b global"
p bB::global
#p b::global     won't work
#p b.global
p b.x  

# and so on