[squeak-dev] The Inbox: Collections-nice.423.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Sep 30 20:12:47 UTC 2011
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-nice.423.mcz
==================== Summary ====================
Name: Collections-nice.423
Author: nice
Time: 30 September 2011, 10:12:20.333 pm
UUID: 7613573f-6d08-9d4c-9d9e-2eaacff799fe
Ancestors: Collections-ul.422
#size and #do: default implementation will cause an infinite loop in every new subclass of SequenceableCollection without any form of warning to the poor programmer.
It's simple to avoid this bad behavior by:
- moving Collection>>size implementation to the sole place where it is used (LinkedList)
- replacing it with a subclassResponsibility.
=============== Diff against Collections-ul.422 ===============
Item was changed:
----- Method: Collection>>size (in category 'accessing') -----
size
"Answer how many elements the receiver contains."
+ ^self subclassResponsibility!
- | tally |
- tally := 0.
- self do: [:each | tally := tally + 1].
- ^ tally!
Item was added:
+ ----- Method: LinkedList>>size (in category 'accessing') -----
+ size
+ "Answer how many elements the receiver contains."
+
+ | tally |
+ tally := 0.
+ self do: [:each | tally := tally + 1].
+ ^ tally!
More information about the Squeak-dev
mailing list
|