From: Simon Strandgaard Date: 2004-02-26T00:29:46+09:00 Subject: Re: Operators +, += and = in Ruby 2 On Wed, 25 Feb 2004 16:12:16 +0100, Robert Klemme wrote: [snip] > What do others think? Did I overlook something? > It would be really nice to be able to overload '+=', so that #close can be invoked correct. server> ruby a.rb 0 1 server> expand -t2 a.rb class A @@count = 0 def initialize(value=nil) @value = value || 0 @@count += 1 end attr_reader :value def close @@count -= 1 end def A.count @@count end def +(value) A.new(@value + value) end end p A.count a = A.new a += 5 a.close p A.count server> -- Simon Strandgaard