On Aug 26, 2007, at 11:01 , Fabio Filasieno wrote:
collection := OrderedCollection new. collection add:1.
evaluates to one. Why ? Why not to collection ?
You do not always add a simple value but the result of an expression. Having the #add: return the argument sometimes lets you avoid introducing a temporary variable. It is more useful this way, and for the cases where you actually want the collection you can use a cascade.
A similar point can be made that setters should return the argument instead of the receiver, although usually in Squeak they do not (Tweak revises that policy).
- Bert -