Bug #3222: Can bignums have singleton class & methods?
http://redmine.ruby-lang.org/issues/show/3222

Author: Marc-Andre Lafortune
Status: Open, Priority: Normal
Category: core, Target version: 1.9.2
ruby -v: ruby 1.9.2dev (2010-04-30 trunk 27554) [x86_64-darwin10.3.0] 

Fixing up the rubyspecs led me to the following:

  bn = 1 << 100
  class << bn
    def foo
      42
    end
  end
  # => TypeError: can't define singleton method "foo" for Bignum

  bn.define_singleton_method(:foo){42}
  # => TypeError: can't define singleton method "foo" for Bignum

On the other hand...

  module Bar
    def foo
      42
    end
  end
  class << bn
    include Bar
  end
  bn.foo # => 42

If Ruby won't allow singleton methods for Bignum, then shouldn't it disallow access to the singleton class completely?

See also issue #601


----------------------------------------
http://redmine.ruby-lang.org