Collection.st
changeset 14528 38c6ed4d5d97
parent 14401 bdfdcb8d0386
child 14538 c75ea074762a
--- a/Collection.st	Fri Nov 23 13:46:54 2012 +0100
+++ b/Collection.st	Fri Nov 23 17:35:50 2012 +0100
@@ -923,6 +923,23 @@
     "Modified: 12.4.1996 / 13:30:54 / cg"
 !
 
+addAllNonNilElements:aCollection
+    "add all non-nil elements of the argument, aCollection to the receiver.
+     Use this, when operating on a Set, that should not hold nil.
+     Answer the argument, aCollection."
+
+    aCollection do:[:eachElement |
+        eachElement notNil ifTrue:[
+            self add:eachElement
+        ].
+    ].
+    ^ aCollection
+
+    "
+     #(1 2 3 4) asSet addAllNonNilElements:#(5 nil 6 7 8); yourself
+    "
+!
+
 addFirst:anObject
     "add the argument, anObject to the receiver.
      If the receiver is ordered, the new element will be added at the beginning.
@@ -4412,11 +4429,11 @@
 !Collection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.282 2012-10-19 12:03:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.283 2012-11-23 16:35:50 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.282 2012-10-19 12:03:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.283 2012-11-23 16:35:50 stefan Exp $'
 ! !
 
 Collection initialize!