Created
July 30, 2012 11:49
-
-
Save edtsech/3206400 to your computer and use it in GitHub Desktop.
Two classes with the same name, but with different obejct_id.
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
ContentFor = Class.new | |
x = ContentFor.new | |
puts x.class.object_id # => 2266662780 | |
# puts x.class.name | |
ContentFor = Class.new | |
y = ContentFor.new | |
puts x.class.object_id # => 2266662780 | |
puts x.class.name # => nil | |
puts y.class.object_id # => 2266662700 | |
puts y.class.name # => nil | |
puts ContentFor.object_id # => 2266662700 |
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
ContentFor = Class.new | |
x = ContentFor.new | |
puts x.class.object_id # => 2266662780 | |
puts x.class.name # => ContentFor | |
ContentFor = Class.new | |
y = ContentFor.new | |
puts x.class.object_id # => 2266662780 | |
puts x.class.name # => ContentFor | |
puts y.class.object_id # => 2266662700 | |
puts y.class.name # => ContentFor | |
puts ContentFor.object_id # => 2266662700 |
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
class ContentFor < Liquid::Tag | |
... | |
end | |
..... | |
node.class # => ContentFor | |
node.class.object_id # => 70174154320900 | |
ContentFor.object_id # => 70174175475880 | |
node.is_a? ContentFor # => false | |
node.class.name == "ContentFor" # => true | |
@Mik-die я просто думал имя как-то зависит от достижимости, раз ты акцентировал внимание на том, что недостижимые помнят имя. Но не суть, теперь понял.
Да, вижу, в консоли это не было заметно..
http://codepad.org/gGZzowA9
http://codepad.org/vYznrZoO
Наверное имя как-то лениво определяется.. там си, не хочу смотреть :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Вот мой вывод: