--- a/Collection.st Thu Jan 22 00:23:21 2009 +0100
+++ b/Collection.st Thu Jan 22 21:24:47 2009 +0100
@@ -228,6 +228,7 @@
^ self withSize:n
! !
+
!Collection class methodsFor:'Signal constants'!
emptyCollectionSignal
@@ -383,6 +384,7 @@
].
! !
+
!Collection methodsFor:'accessing'!
anElement
@@ -1040,16 +1042,15 @@
Consider a collection of measurement or physical objects, 0 would be the unitless
value and would not be appropriate to add with the unit-ed objects."
- self emptyCheck.
+ self isEmpty ifTrue:[^ 0].
+
^ self
inject:(self first class zero)
into:[:accum :each | accum + each].
"
- TestCase should: [ { } sum ] raise:Error.
- TestCase should: [ '' sum ] raise:Error.
-
+ TestCase assert: ( { } sum = 0 ).
TestCase assert: ( { 1 } sum = 1 ).
TestCase assert: ( { 1. 2. 3. 4. } sum = 10 ).
TestCase assert: ( (1 to:10) sum = 55 ).
@@ -2381,7 +2382,6 @@
! !
-
!Collection methodsFor:'operations'!
decrementAt:aKey
@@ -3340,7 +3340,7 @@
!Collection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.216 2009-01-16 13:55:49 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.217 2009-01-22 20:24:47 cg Exp $'
! !
Collection initialize!