Ver código fonte

Fixed HashedCollection >> withIndexDo:

Nicolas Petton 11 anos atrás
pai
commit
3ec99a05d3

+ 4 - 2
js/Kernel-Collections.deploy.js

@@ -1223,9 +1223,11 @@ smalltalk.method({
 selector: "withIndexDo:",
 fn: function (aBlock){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
_st(self)._keysAndValuesDo_(aBlock);
+return smalltalk.withContext(function($ctx1) { 
_st(self)._keysAndValuesDo_((function(key,value){
+return smalltalk.withContext(function($ctx2) {
return _st(aBlock)._value_value_(value,key);
+}, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
 return self}, function($ctx1) {$ctx1.fill(self,"withIndexDo:",{aBlock:aBlock},smalltalk.HashedCollection)})},
-messageSends: ["keysAndValuesDo:"]}),
+messageSends: ["keysAndValuesDo:", "value:value:"]}),
 smalltalk.HashedCollection);
 
 

+ 5 - 3
js/Kernel-Collections.js

@@ -1638,11 +1638,13 @@ selector: "withIndexDo:",
 category: 'enumerating',
 fn: function (aBlock){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
_st(self)._keysAndValuesDo_(aBlock);
+return smalltalk.withContext(function($ctx1) { 
_st(self)._keysAndValuesDo_((function(key,value){
+return smalltalk.withContext(function($ctx2) {
return _st(aBlock)._value_value_(value,key);
+}, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
 return self}, function($ctx1) {$ctx1.fill(self,"withIndexDo:",{aBlock:aBlock},smalltalk.HashedCollection)})},
 args: ["aBlock"],
-source: "withIndexDo: aBlock\x0a\x09self keysAndValuesDo: aBlock",
-messageSends: ["keysAndValuesDo:"],
+source: "withIndexDo: aBlock\x0a\x09self keysAndValuesDo: [ :key :value | aBlock value: value value: key ]",
+messageSends: ["keysAndValuesDo:", "value:value:"],
 referencedClasses: []
 }),
 smalltalk.HashedCollection);

+ 1 - 1
st/Kernel-Collections.st

@@ -540,7 +540,7 @@ valuesDo: aBlock
 !
 
 withIndexDo: aBlock
-	self keysAndValuesDo: aBlock
+	self keysAndValuesDo: [ :key :value | aBlock value: value value: key ]
 ! !
 
 !HashedCollection methodsFor: 'printing'!