Hi --

On Thu, 11 May 2006, Tim Uckun wrote:

> I was reading through the source code of the DBI module and I saw this
> line there.
>
> class << self
>
> What does this statement do?

In general, this:

   class << obj

puts you into a class definition block for the singleton class of obj.
The singleton class of obj is where those methods are stored that are
unique to obj.  So it's like a class-definition interface to obj's
unique behaviors.

class << self is just a case where the object whose singleton class
you're gaining access to is the current object (self).


David

-- 
David A. Black (dblack / wobblini.net)
* Ruby Power and Light, LLC (http://www.rubypowerandlight.com)
   > Ruby and Rails consultancy and training
* Author of "Ruby for Rails" from Manning Publications!
   > http://www.manning.com/black