-
-
Save anonymous/e75e25bf1da411cd77f8 to your computer and use it in GitHub Desktop.
Ruby: playing with modules
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
#!/usr/bin/env ruby | |
module CoolModule1 | |
class CoolClass1; end | |
end | |
coolmodule2 = Module.new do | |
class CoolClass2; end | |
end | |
p CoolModule1.constants.any? # => true | |
p coolmodule2.constants.any? # => false # Why? | |
p CoolModule1.const_defined? :CoolClass1 # => true | |
p coolmodule2.const_defined? :CoolClass2 # => true # wait, what? | |
# help? :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment