#FEATURE by stefan
authorStefan Vogel <sv@exept.de>
Tue, 20 Mar 2018 15:51:21 +0100
changeset 22638 b6a1935838d0
parent 22637 cbd7ba691053
child 22639 468e2dcbd196
#FEATURE by stefan class: Collection added: #asCollectionOrEmptyIfNil #doIfNotNil:
Collection.st
--- a/Collection.st	Tue Mar 20 15:03:36 2018 +0100
+++ b/Collection.st	Tue Mar 20 15:51:21 2018 +0100
@@ -1739,6 +1739,15 @@
     self do:aBlock
 !
 
+asCollectionOrEmptyIfNil
+    "return myself as a Collection.
+     I am already a Collection."
+
+    ^ self
+
+    "Created: / 20-03-2018 / 15:23:18 / stefan"
+!
+
 asDictionary
     "return a Dictionary with the receiver collection's elements,
      using the original keys of the receiver as dictionary key.
@@ -2997,6 +3006,14 @@
     "Created: / 28-02-2012 / 21:11:41 / cg"
 !
 
+doIfNotNil:aBlock
+    "evaluate aBlock for each element in the collection"
+
+    ^ self do:aBlock
+
+    "Created: / 20-03-2018 / 15:37:29 / stefan"
+!
+
 doWhileTrue:aBlock
     "evaluate the argument, aBlock for each element,
      until the block evaluates to false.