From: Kedar Mhaswade Date: 2013-03-15T08:09:56+09:00 Subject: Re: confusion with singleton method call Love U Ruby wrote in post #1101669: > What I know singleton methods can be called by the objects, on which it > is defined. Now in the below example `C` is also > an object of `Class` and singleton method `a_class_method` defined on > the `Class` object `C`. So how does another `Class` object `D` able > to call `a_class_method`? How does object `individuation` principle > holds in this example? > > > class C > end > #=> nil > def C.a_class_method > puts "Singleton method defined on #{self}" > end > #=> nil > C.a_class_method > #Singleton method defined on C > #=> nil > class D < C > end > #=> nil > D.a_class_method > #Singleton method defined on D > #=> nil If you did D.method :a_class_method you'll see: # This happens because D's singleton class inherits from C's singleton class, which happens because D inherits from C (and as such, D _is_ C). -- Posted via http://www.ruby-forum.com/.