Yesterday, I found the following code in RSpec:
class OptionParser < ::OptionParser What does this do? What is the difference between this and class OptionParser < NameSpace::OptionParser?
Yesterday, I found the following code in RSpec:
class OptionParser < ::OptionParser What does this do? What is the difference between this and class OptionParser < NameSpace::OptionParser?
An runnable example might explain the idea best:
class C def initialize puts "At top level" end end module M class C def initialize puts "In module M" end end class P < C def initialize super end end class Q < ::C def initialize super end end end M::P.new M::Q.new Produces when run:
In module M At top level ::OptionParser refers to the standard library class