Collection.st
branchjv
changeset 20205 03e626304d06
parent 20154 52198bb46e04
parent 20187 567d9526c40d
child 20220 874c664d2cbd
--- a/Collection.st	Fri Jul 29 21:39:49 2016 +0100
+++ b/Collection.st	Fri Jul 29 21:40:03 2016 +0100
@@ -251,11 +251,9 @@
     "return a new Collection with all elements taken from the argument,
      aCollection"
 
-    |newCollection|
-
-    newCollection := self new.
-    newCollection addAll:aCollection.
-    ^newCollection
+    ^ self new
+        addAll:aCollection;
+        yourself.
 !
 
 withSize:n
@@ -941,11 +939,15 @@
     "return a collection containing all values of the receiver.
      This is to make value access to an OrderedDictionary compatible with any-Collection"
 
-    |aCollection|
-
-    aCollection := OrderedCollection new.
-    self do:[:value| aCollection add:value].
-    ^ aCollection
+    ^ OrderedCollection new
+        addAll:self;
+        yourself.
+
+    "
+        #(1 2 3 4 5) values
+        #(1 2 3 4 5) asSet values
+        #(1 2 3 4 5) asOrderedSet values
+    "
 ! !
 
 !Collection methodsFor:'adding & removing'!
@@ -1116,7 +1118,7 @@
 remove:anObject ifAbsent:exceptionBlock
     "search for the first element, which is equal to anObject;
      if found, remove and return it.
-     If not found, return the the value of the exceptionBlock.
+     If not found, return the value of the exceptionBlock.
      Uses equality compare (=) to search for the occurrence.
      An error is raised here - it is to be implemented by a concrete subclass."
 
@@ -1376,7 +1378,7 @@
 removeIdentical:anObject ifAbsent:exceptionBlock
     "search for the first element, which is identical to anObject;
      if found, remove and return it.
-     If not found, return the the value of the exceptionBlock.
+     If not found, return the value of the exceptionBlock.
      Uses identity compare (==) to search for the occurrence.
      An error is raised here - it is to be implemented by a concrete subclass."