Set.st
branchjv
changeset 18043 03660093fe98
parent 18037 4cf874da38c9
parent 15000 4d10fba9aed4
child 18045 c0c600e0d3b3
--- a/Set.st	Thu Mar 28 12:21:50 2013 +0000
+++ b/Set.st	Mon Apr 01 13:42:45 2013 +0100
@@ -677,6 +677,25 @@
     "
 ! !
 
+!Set methodsFor:'converting'!
+
+asNewSet
+    "make sure to return a unique new set"
+
+    "could be an instance of a subclass..."
+    self class == Set ifTrue:[
+        ^ self copy
+    ].
+    ^ super asSet
+
+    " 
+        |s|
+        s := #(1 2 3 4) asSet.
+        self assert:(s ~~ s asNewSet).
+        self assert:(s = s asNewSet).
+     "
+! !
+
 !Set methodsFor:'copying'!
 
 postCopy
@@ -711,6 +730,7 @@
 ! !
 
 
+
 !Set methodsFor:'obsolete set operations'!
 
 + aCollection
@@ -1130,6 +1150,7 @@
     ^ tally
 ! !
 
+
 !Set methodsFor:'testing'!
 
 capacity 
@@ -1231,11 +1252,11 @@
 !Set class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.118 2013-03-19 09:22:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.119 2013-03-28 23:22:26 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.118 2013-03-19 09:22:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.119 2013-03-28 23:22:26 stefan Exp $'
 ! !