Last active
December 16, 2015 02:19
-
-
Save cirode/5361361 to your computer and use it in GitHub Desktop.
This show the difference between naming classes with the :: syntax or wrapping with an explicit module. Try and guess what will happen when you run the code below
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module C | |
class B | |
def initialize | |
puts 'B' | |
end | |
end | |
end | |
module C | |
class D | |
def initialize | |
puts 'D' | |
B.new | |
end | |
end | |
end | |
class C::A | |
def initialize | |
puts 'A' | |
B.new | |
end | |
end | |
C::D.new | |
C::A.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment