Created
July 9, 2009 06:11
-
-
Save maxim/143464 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
# 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