From: "Chr. Rippel" Date: 2001-12-30T10:17:39+09:00 Subject: [ruby-talk:29679] Re: special case? > > irb(main):001:0> class << 1 > > irb(main):002:1> def meth > > irb(main):003:2> end > > irb(main):004:1> end > > TypeError: no virtual class for Fixnum > > from (irb):1 .... > It's rather a hole. The current implementation of > primitive types does not lend itself well to singletons. > (I think it's just Fixnum, true, false, and nil that can't > have singletons.) That isn't quite correct: def nil.yes; end puts nil.singleton_methods # => yes On the other hand class << nil; end def 1.yes; end both raise exceptions ... > I believe this will change in the future, from what I've > heard Matz say in the past. Bignums (and Floats) already have singletons but they are somewhat useless. For example, a = 2<< 34 aa = 2<< 34 yields p (a.equal? aa) # => false thus even if you define def a.yes; end you cannot call aa.yes Something like ``approximate singleton classes'' would probably more useful (especially for Floats) but probably difficult to implement. .... /Christoph