An interesting class naming behavior in Ruby
November 30th, 2007The code explains it all:
#!/usr/bin/env ruby klass = Class.new klass.name # => '' Foo = klass klass.name # => 'Foo' Foo.name # => 'Foo' Bar = Foo Bar.name # => 'Foo'
Seems strange, but oddly makes sense, huh?












November 30th, 2007 at 4:38 pm
Why klass.name # => ‘Foo’ after Foo = klass makes sense? Foo is not a reference to klass, but after you Foo = nil, klass.name is still ‘Foo’ :-P
Weird, someone can explain that? :-D