Skip to content

Instantly share code, notes, and snippets.

@cirode
Last active December 16, 2015 02:19
Show Gist options
  • Save cirode/5361361 to your computer and use it in GitHub Desktop.
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
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