Skip to content

Instantly share code, notes, and snippets.

@skiz
Created January 12, 2012 17:34
Show Gist options
  • Save skiz/1601944 to your computer and use it in GitHub Desktop.
Save skiz/1601944 to your computer and use it in GitHub Desktop.
Module#const_defined? weirdness in Ruby 1.9.3
mod = Module.new do
Junk = 123
end
mod.const_defined?(:Junk) #=> false
mod.const_defined?(:Junk, false) #=> ArgumentError
mod.constants #=> []
module Foo
Junk = 123
end
Foo.const_defined?(:Junk) #=> true
Foo.const_defined?(:Junk, false) #=> ArgumentError
Foo.constants #=> ["Junk"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment