Browse Source

Push at:ifAbsentPut: up

Herbert Vojčík 11 years ago
parent
commit
6e6add75bf
2 changed files with 26 additions and 26 deletions
  1. 21 21
      js/Kernel-Collections.js
  2. 5 5
      st/Kernel-Collections.st

+ 21 - 21
js/Kernel-Collections.js

@@ -1153,6 +1153,27 @@ referencedClasses: []
 }),
 }),
 smalltalk.IndexableCollection);
 smalltalk.IndexableCollection);
 
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "at:ifAbsentPut:",
+protocol: 'accessing',
+fn: function (aKey,aBlock){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=self._at_ifAbsent_(aKey,(function(){
+return smalltalk.withContext(function($ctx2) {
+return self._at_put_(aKey,_st(aBlock)._value());
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"at:ifAbsentPut:",{aKey:aKey,aBlock:aBlock},smalltalk.IndexableCollection)})},
+args: ["aKey", "aBlock"],
+source: "at: aKey ifAbsentPut: aBlock\x0a\x09^ self at: aKey ifAbsent: [\x0a\x09\x09self at: aKey put: aBlock value ]",
+messageSends: ["at:ifAbsent:", "at:put:", "value"],
+referencedClasses: []
+}),
+smalltalk.IndexableCollection);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 smalltalk.method({
 smalltalk.method({
 selector: "at:ifPresent:",
 selector: "at:ifPresent:",
@@ -1474,27 +1495,6 @@ referencedClasses: []
 }),
 }),
 smalltalk.HashedCollection);
 smalltalk.HashedCollection);
 
 
-smalltalk.addMethod(
-smalltalk.method({
-selector: "at:ifAbsentPut:",
-protocol: 'accessing',
-fn: function (aKey,aBlock){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=self._at_ifAbsent_(aKey,(function(){
-return smalltalk.withContext(function($ctx2) {
-return self._at_put_(aKey,_st(aBlock)._value());
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"at:ifAbsentPut:",{aKey:aKey,aBlock:aBlock},smalltalk.HashedCollection)})},
-args: ["aKey", "aBlock"],
-source: "at: aKey ifAbsentPut: aBlock\x0a\x09^ self at: aKey ifAbsent: [\x0a\x09\x09self at: aKey put: aBlock value ]",
-messageSends: ["at:ifAbsent:", "at:put:", "value"],
-referencedClasses: []
-}),
-smalltalk.HashedCollection);
-
 smalltalk.addMethod(
 smalltalk.addMethod(
 smalltalk.method({
 smalltalk.method({
 selector: "at:ifPresent:ifAbsent:",
 selector: "at:ifPresent:ifAbsent:",

+ 5 - 5
st/Kernel-Collections.st

@@ -377,6 +377,11 @@ at: anIndex ifAbsent: aBlock
 	self subclassResponsibility
 	self subclassResponsibility
 !
 !
 
 
+at: aKey ifAbsentPut: aBlock
+	^ self at: aKey ifAbsent: [
+		self at: aKey put: aBlock value ]
+!
+
 at: anIndex ifPresent: aBlock
 at: anIndex ifPresent: aBlock
 	"Lookup the given index in the receiver.
 	"Lookup the given index in the receiver.
 	If it is present, answer the value of evaluating aBlock with the value stored at anIndex.
 	If it is present, answer the value of evaluating aBlock with the value stored at anIndex.
@@ -453,11 +458,6 @@ at: aKey ifAbsent: aBlock
 		ifFalse: aBlock
 		ifFalse: aBlock
 !
 !
 
 
-at: aKey ifAbsentPut: aBlock
-	^ self at: aKey ifAbsent: [
-		self at: aKey put: aBlock value ]
-!
-
 at: aKey ifPresent: aBlock ifAbsent: anotherBlock
 at: aKey ifPresent: aBlock ifAbsent: anotherBlock
 	"Lookup the given key in the receiver.
 	"Lookup the given key in the receiver.
 	If it is present, answer the value of evaluating the oneArgBlock with the value associated with the key,
 	If it is present, answer the value of evaluating the oneArgBlock with the value associated with the key,