[GOODIE] Arithmetic assignments (+= and friends)

Andreas Raab Andreas.Raab at gmx.de
Mon Jun 17 13:58:04 UTC 2002


Bert,

> I think it's not too far-fetched to use an inplace
> modifying loop like
> 
> 	coll do: [:each | each += something]
> 
> which would not work anymore with your approach. 

But this example would work neither if you need polymorphic receivers
(like integers). In addition, implementing 

Collection>>+= something
	| tmp |
	self keysAndValuesDo:[:key :val|
		tmp := val.
		tmp += something.
		self at: key put: val].

would solve the problem quite nicely.

Cheers,
  - Andreas




More information about the Squeak-dev mailing list