surge
6/20/2007 9:40:00 PM
Hello,
I have trouble understanding the need for the class << self idiom. For
example, let's say I have this class:
class My_Class
def method_1
end
end
Now, I want to extend that class. I can do:
class My_Class
def method_2
end
end
or:
class My_Class
class << self
def method_2
end
end
end
I understand that in the second case we're extending the singleton
class of My_Class, but why is the second form so often used in Ruby
vs. the other form? Isn't the end result identical?