0

I know that to use class inheritance in Ruby, the following syntax is used:

class MyNewClass < SomeClass
...
end

I also know that nesting in namespaces is identified using :::

class SomeNameSpace::MyNewClass < SomeNameOtherSpace::SomeClass 
...
end

However, what does the following syntax mean?

class SomeNameSpace::MyNewClass < ::SomeClass 
...
end

I expect that ::SomeClass (so without anything before the ::)is a shorthand for something, but what exactly does it mean?

Qqwy
  • 5,214
  • 5
  • 42
  • 83

1 Answers1

1

::SomeClass means SomeClass class from top namespace. :: is specially used to refer the top namespace from deep inside other modules.

Babar Al-Amin
  • 3,939
  • 1
  • 16
  • 20
  • So this means that if I have a module overriding, say, one of the base classes like `MyHTMLFunModule::String`, I can still refer to the default `String` by using `::String`? – Qqwy Mar 05 '16 at 21:19