I asked the same question yesterday...
It is just another way add singleton methods to the outer scope
(probably saw this in a module?). So this:
module Foo
class << self
def a; end
def b; end
end
end
is the same as:
module Foo
def Foo.a; end
def Foo.b; end
end
I guess people use this style to organize sets of singleton methods so
that they are clearly separated from the rest of the module. (Since
methods defined regularly won't be used until the module is mixed in
somewhere...) Saves you from having to write the "Foo." part before
every method too...
-Jeff
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?