Set.st
changeset 15000 4d10fba9aed4
parent 14895 1112f18b10d1
child 15036 f86ace435ad0
child 18043 03660093fe98
--- a/Set.st	Fri Mar 29 00:21:40 2013 +0100
+++ b/Set.st	Fri Mar 29 00:22:26 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 $'
 ! !