1
0
Prechádzať zdrojové kódy

add Collection>>ifEmpty: >>ifNotEmpty:

Laurent Laffont 13 rokov pred
rodič
commit
33ba58f8cd
3 zmenil súbory, kde vykonal 61 pridanie a 1 odobranie
  1. 22 0
      js/Kernel.deploy.js
  2. 31 1
      js/Kernel.js
  3. 8 0
      st/Kernel.st

+ 22 - 0
js/Kernel.deploy.js

@@ -2826,6 +2826,28 @@ return self;}
 }),
 smalltalk.Collection);
 
+smalltalk.addMethod(
+'_ifNotEmpty_',
+smalltalk.method({
+selector: 'ifNotEmpty:',
+fn: function (aBlock){
+var self=this;
+smalltalk.send(smalltalk.send(self, "_notEmpty", []), "_ifTrue_", [aBlock]);
+return self;}
+}),
+smalltalk.Collection);
+
+smalltalk.addMethod(
+'_ifEmpty_',
+smalltalk.method({
+selector: 'ifEmpty:',
+fn: function (aBlock){
+var self=this;
+smalltalk.send(smalltalk.send(self, "_isEmpty", []), "_ifTrue_", [aBlock]);
+return self;}
+}),
+smalltalk.Collection);
+
 
 smalltalk.addMethod(
 '_streamClass',

+ 31 - 1
js/Kernel.js

@@ -1281,7 +1281,7 @@ smalltalk.send(self, "_addCompiledMethod_", [method]);
 return self;},
 source: unescape('compile%3A%20aString%20category%3A%20anotherString%0A%09%7C%20method%20%7C%0A%09method%20%3A%3D%20Compiler%20new%20load%3A%20aString%20forClass%3A%20self.%0A%09method%20category%3A%20anotherString.%0A%09self%20addCompiledMethod%3A%20method'),
 messageSends: ["load:forClass:", "new", "category:", "addCompiledMethod:"],
-referencedClasses: [smalltalk.Compiler]
+referencedClasses: [smalltalk.nil]
 }),
 smalltalk.Behavior);
 
@@ -3795,6 +3795,36 @@ referencedClasses: []
 }),
 smalltalk.Collection);
 
+smalltalk.addMethod(
+'_ifNotEmpty_',
+smalltalk.method({
+selector: 'ifNotEmpty:',
+category: 'testing',
+fn: function (aBlock){
+var self=this;
+smalltalk.send(smalltalk.send(self, "_notEmpty", []), "_ifTrue_", [aBlock]);
+return self;},
+source: unescape('ifNotEmpty%3A%20aBlock%0A%09self%20notEmpty%20ifTrue%3A%20aBlock.'),
+messageSends: ["ifTrue:", "notEmpty"],
+referencedClasses: []
+}),
+smalltalk.Collection);
+
+smalltalk.addMethod(
+'_ifEmpty_',
+smalltalk.method({
+selector: 'ifEmpty:',
+category: 'testing',
+fn: function (aBlock){
+var self=this;
+smalltalk.send(smalltalk.send(self, "_isEmpty", []), "_ifTrue_", [aBlock]);
+return self;},
+source: unescape('ifEmpty%3A%20aBlock%0A%09self%20isEmpty%20ifTrue%3A%20aBlock.'),
+messageSends: ["ifTrue:", "isEmpty"],
+referencedClasses: []
+}),
+smalltalk.Collection);
+
 
 smalltalk.addMethod(
 '_streamClass',

+ 8 - 0
st/Kernel.st

@@ -1341,6 +1341,14 @@ notEmpty
 
 isEmpty
 	^self size = 0
+!
+
+ifNotEmpty: aBlock
+	self notEmpty ifTrue: aBlock.
+!
+
+ifEmpty: aBlock
+	self isEmpty ifTrue: aBlock.
 ! !
 
 !Collection class methodsFor: 'accessing'!