Created
September 13, 2015 20:11
-
-
Save sacarlson/25b99990338f1d04ce5d to your computer and use it in GitHub Desktop.
This file contains 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 Module2 | |
class Class2 | |
include Module2 | |
end | |
def version | |
return "0.1.0" | |
end | |
end | |
include Module2 | |
# if this function name is version instead of version2 we get | |
#test_module.rb:28:in `<main>': private method `version' called for Module2:Module (NoMethodError) | |
def version | |
return "0.2.0" | |
end | |
x = Module2::Class2.new | |
# this puts "#{Module2.version}" won't work without include | |
puts "#{x.version}" | |
puts "#{Module2::Class2.new.version}" | |
# can't do puts "#{Module2.version}" when version not renamed to version2 | |
#puts "#{Module2.version}" | |
puts "#{version}" | |
#result | |
#0.1.0 | |
#0.1.0 | |
#0.2.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment