Given a Ruby class with a static method like
class Foo
def self.bar
puts "Hello"
end
end
I always accessed the method via
Foo.bar
However, I just noticed that you can also do
Foo::bar
Why is that? Is there a semantic difference? My initial idea was that it's a matter of treating Foo
as a class object (in which case the first version seems plausible) vs. treating it as a "namespace" like a module, in which case the second version makes sense.