I just happened upon singleton classes, and was wondering two things:
- There’s no difference between these two codes, right? Is there an
advantage or disadvantage over either? Does Ruby put bar() into the
same virtual class object for both?
class Foo
class << self
def bar
end
end
end
class Foo
def self.bar
end
end
- A singleton class has nothing to do with the singleton design
pattern, right? They only share the same name because there is only
ever one of them.