From: Rajinder Yadav Date: 2009-10-31T03:41:03+09:00 Subject: Re: Ruby doesn't implement x++ for Fixnum's because ??? On Fri, Oct 30, 2009 at 1:51 PM, lith wrote: >> IMHO the story goes like this: absence of postfix ++ and -- is a >> consequence of the fact that numeric types are immutable in Ruby which >> makes an assignment necessary for these operators. > > You could "decorate" it with such a method though. This could look > something like this: > >    class FixNum < BasicObject > >        def initialize(fn) >            @fn = fn >        end > >        def succ! >            @fn += 1 >        end > >        def method_missing(*args, &block) >            @fn.send(*args, &block) >        end Hi lith, can you extol your knowledge on me about what method_missing is doing? I get what *args and &block is, but not quite sure what's going on? >    end > >    a = FixNum.new(1) >    a.succ! >    p a >    => 2 > > Whether this is good practice or marginally useful ... > > -- Kind Regards, Rajinder Yadav http://DevMentor.org Do Good! - Share Freely, Enrich and Empower people to Transform their lives.