Forum: Ruby What kind of inheritance is that?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Luiz Vitor Martinez C. (Guest)
on 2009-02-03 20:33
(Received via mailing list)
I founded this code at WEBrick library:

  class HTTPServer < ::WEBrick::GenericServer
    def initialize(config={}, default=Config::HTTP)
      super


What kind of inheritance is HTTPServer << ::WEBrick, I don't undestand
de ::
before. What does it means?


--
Regards,

Luiz Vitor Martinez C.
cel.: (11) 8187-8662
blog: rubz.org
engineer student at maua.br

"Posso nunca chegar a ser o melhor engenheiro do mundo, mas tenha
certeza de
que eu vou lutar com todas as minhas forças para ser o melhor engenheiro
que
eu puder ser"
Tom L. (Guest)
on 2009-02-03 20:38
(Received via mailing list)
> What kind of inheritance is HTTPServer << ::WEBrick, I don't undestand de ::
> before. What does it means?

It's there to make sure the right class is used. Try:

class A
    def foo
        "a"
    end
end

module B
    class A
        def foo
            "ba"
        end
    end

    p A.new.foo
    p ::A.new.foo
end

"ba"
"a"
=> nil
This topic is locked and can not be replied to.