From: "Ara.T.Howard" Date: 2005-05-19T04:30:13+09:00 Subject: new singleton class relationship am i the only one who finds this confusing? harp:~/build/ruby > cat a.rb class Class def singleton_class; class << self; self; end; end end class Parent end class Child < Parent end puts "Child < Parent #=> #{ (Child < Parent).inspect }" puts "Parent.ancestors #=> #{ Parent.ancestors.inspect }" puts "Child.ancestors #=> #{ Child.ancestors.inspect }" puts puts "Child.singleton_class < Parent.singleton_class #=> #{ (Child.singleton_class < Parent.singleton_class).inspect }" puts "Parent.singleton_class.ancestors #=> #{ Parent.singleton_class.ancestors.inspect }" puts "Child.singleton_class.ancestors #=> #{ Child.singleton_class.ancestors.inspect }" puts harp:~/build/ruby > ruby --version ruby 1.8.3 (2005-05-16) [i686-linux] harp:~/build/ruby > ruby a.rb Child < Parent #=> true Parent.ancestors #=> [Parent, Object, Kernel] Child.ancestors #=> [Child, Parent, Object, Kernel] Child.singleton_class < Parent.singleton_class #=> nil Parent.singleton_class.ancestors #=> [Class, Module, Object, Kernel] Child.singleton_class.ancestors #=> [Class, Module, Object, Kernel] harp:~/build/ruby > ./ruby --version ruby 1.9.0 (2005-05-16) [i686-linux] harp:~/build/ruby > ./ruby a.rb Child < Parent #=> true Parent.ancestors #=> [Parent, Object, Kernel] Child.ancestors #=> [Child, Parent, Object, Kernel] Child.singleton_class < Parent.singleton_class #=> true Parent.singleton_class.ancestors #=> [Class, Module, Object, Kernel] Child.singleton_class.ancestors #=> [Class, Module, Object, Kernel] so - how can 'Child < Parent #=> true' when they have no ancestors in common? note that i think it __should__ be true - but shouldn't there be at least one common ancestor then? it seems like Parent's singleton class should show up in Child.singleton_class.ancestors doesn't it? cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | renunciation is not getting rid of the things of this world, but accepting | that they pass away. --aitken roshi ===============================================================================