소스 검색

Collection >> copyWithout:

Herbert Vojčík 7 년 전
부모
커밋
1928ec10fc
3개의 변경된 파일44개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      API-CHANGES.txt
  2. 31 0
      src/Kernel-Collections.js
  3. 7 0
      src/Kernel-Collections.st

+ 6 - 0
API-CHANGES.txt

@@ -1,3 +1,9 @@
+0.18.3:
+
++ Collection >>
+  + copyWithout:
+
+
 0.18.2:
 
 * Add Platform-DOM package with DOM-related stuff.

+ 31 - 0
src/Kernel-Collections.js

@@ -812,6 +812,37 @@ messageSends: ["addAll:", "copy", "yourself"]
 }),
 $globals.Collection);
 
+$core.addMethod(
+$core.method({
+selector: "copyWithout:",
+protocol: 'copying',
+fn: function (anObject){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return self._reject_((function(each){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return $recv(each).__eq(anObject);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"copyWithout:",{anObject:anObject},$globals.Collection)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject"],
+source: "copyWithout: anObject\x0a\x09\x22Answer a copy of the receiver that does not contain\x0a\x09any occurrences of anObject.\x22\x0a\x0a\x09^ self reject: [ :each | each = anObject ]",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["reject:", "="]
+}),
+$globals.Collection);
+
 $core.addMethod(
 $core.method({
 selector: "copyWithoutAll:",

+ 7 - 0
src/Kernel-Collections.st

@@ -237,6 +237,13 @@ copyWithAll: aCollection
 	^ self copy addAll: aCollection; yourself
 !
 
+copyWithout: anObject
+	"Answer a copy of the receiver that does not contain
+	any occurrences of anObject."
+
+	^ self reject: [ :each | each = anObject ]
+!
+
 copyWithoutAll: aCollection
 	"Answer a copy of the receiver that does not contain any elements
 	equal to those in aCollection."