From: "Eregon (Benoit Daloze)" Date: 2012-10-27T22:20:15+09:00 Subject: [ruby-core:48472] [ruby-trunk - Feature #3222] Can bignums have singleton class & methods? Issue #3222 has been updated by Eregon (Benoit Daloze). ko1 (Koichi Sasada) wrote: > How about "Freeze" all of Bignum instance? > > It is big change, but I believe no impact on it. It makes sense to me to have them frozen, but I think we would need to freeze all Numeric instances as well for consistency (currently, Fixnum, Rational and Complex can have ivars). ---------------------------------------- Feature #3222: Can bignums have singleton class & methods? https://bugs.ruby-lang.org/issues/3222#change-31801 Author: marcandre (Marc-Andre Lafortune) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 =begin 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 =end -- http://bugs.ruby-lang.org/