From: "Mauricio Fernández" Date: 2004-08-11T06:08:31+09:00 Subject: Re: Singleton class methods On Wed, Aug 11, 2004 at 04:47:17AM +0900, Gennady wrote: > That's kind of what I meant. It seems like when you do > > class Foo > def self.bar > end > end > > method "bar" is added to the list of methods of the original class Foo. > > On the other hand, for > > class Foo > class << self > def bar > end > end > end > > a singleton class is created for class object "Foo" and method "bar" is > defined in that singleton class, with all consequences. Hence, the > difference in implementation. Both create a singleton method, but the scoping is different. See http://www.ruby-talk.com/blade/57274 and http://www.ruby-talk.com/cgi-bin/scat.rb/ruby/ruby-talk/57382 -- Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com