Skip to content

Instantly share code, notes, and snippets.

@maxim
Created July 9, 2009 06:11
Show Gist options
  • Save maxim/143464 to your computer and use it in GitHub Desktop.
Save maxim/143464 to your computer and use it in GitHub Desktop.
# Weird ruby behavior
>> class Foo; end
=> nil
>> defined?(Foo)
=> "constant"
>> defined?("Foo".constantize)
=> "method"
#
# Answer: defined? is a special case, it does not evaluate parameters.
# The "method" is returned because it's looking at #constantize method.
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment