Skip to content

Instantly share code, notes, and snippets.

Created November 11, 2015 15:46
Show Gist options
  • Save anonymous/e75e25bf1da411cd77f8 to your computer and use it in GitHub Desktop.
Save anonymous/e75e25bf1da411cd77f8 to your computer and use it in GitHub Desktop.
Ruby: playing with modules
#!/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