Archive for November, 2007

An interesting class naming behavior in Ruby

Friday, November 30th, 2007

The 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?