From: Martin DeMello Date: 2008-08-29T06:48:29+09:00 Subject: Re: Please don't flame me...why is there no "++" in Ruby again ? On Thu, Aug 28, 2008 at 2:43 PM, Robert Dober wrote: > One could define ++ if one wanted, but it can only work on mutable objects > > class MyInteger > def initialize int; @int = int end > define_method "++" do @int += 1 end > def to_s; @int.to_s end > end > > m = MyInteger.new 41 > puts m > m.send "++" > puts m Also note that this will not do what you expect from other languages m = MyInteger.new 41 n = m puts m puts n m.send "++" puts m puts n martin