Project

General

Profile

Actions

Feature #3222

closed

Can bignums have singleton class & methods?

Added by marcandre (Marc-Andre Lafortune) over 14 years ago. Updated about 12 years ago.

Status:
Closed
Target version:
[ruby-core:29891]

Description

=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


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #601: an instance of Bignum can have singleton methodsClosedmatz (Yukihiro Matsumoto)09/25/2008Actions
Related to Ruby master - Feature #6936: Forbid singleton class and instance variabls for floatClosedko1 (Koichi Sasada)08/27/2012Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0