2010-07-21 20 views

Respuesta

8

Un ejemplo ejecutable podría explicar mejor la idea:

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 

Produce cuando se ejecuta:

In module M 
At top level 
+0

Gracias. Solo déjame confirmar si mi comprensión es correcta. ¿OptionParser se refiere a OptionParser en la biblioteca estándar llamada optparse en mi ejemplo? – suzukimilanpaak

+0

Exactamente. En su ejemplo ':: OptionParser' se refiere a la clase de biblioteca estándar – bjg

Cuestiones relacionadas