ソースを参照

Merge pull request #75 from bromagosa/master

SequenceableCollection >> #atRandom
Nicolas Petton 13 年 前
コミット
a97855a25e
3 ファイル変更31 行追加0 行削除
  1. 11 0
      js/Kernel.deploy.js
  2. 16 0
      js/Kernel.js
  3. 4 0
      st/Kernel.st

+ 11 - 0
js/Kernel.deploy.js

@@ -3488,6 +3488,17 @@ return self;}
 }),
 smalltalk.SequenceableCollection);
 
+smalltalk.addMethod(
+'_atRandom',
+smalltalk.method({
+selector: 'atRandom',
+fn: function (){
+var self=this;
+return smalltalk.send(self, "_at_", [smalltalk.send(smalltalk.send(self, "_size", []), "_atRandom", [])]);
+return self;}
+}),
+smalltalk.SequenceableCollection);
+
 
 
 smalltalk.addClass('String', smalltalk.SequenceableCollection, [], 'Kernel');

+ 16 - 0
js/Kernel.js

@@ -4980,6 +4980,22 @@ referencedClasses: []
 }),
 smalltalk.SequenceableCollection);
 
+smalltalk.addMethod(
+unescape('_atRandom'),
+smalltalk.method({
+selector: unescape('atRandom'),
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.send(self, "_at_", [smalltalk.send(smalltalk.send(self, "_size", []), "_atRandom", [])]);
+return self;},
+args: [],
+source: unescape('atRandom%0A%09%5E%20self%20at%3A%20self%20size%20atRandom'),
+messageSends: ["at:", "atRandom", "size"],
+referencedClasses: []
+}),
+smalltalk.SequenceableCollection);
+
 
 
 smalltalk.addClass('String', smalltalk.SequenceableCollection, [], 'Kernel');

+ 4 - 0
st/Kernel.st

@@ -1686,6 +1686,10 @@ indexOf: anObject startingAt: start
 	within the receiver. If the receiver does not contain anElement, 
 	answer 0."
 	^self indexOf: anObject startingAt: start ifAbsent: [0]
+!
+
+atRandom
+	^ self at: self size atRandom
 ! !
 
 !SequenceableCollection methodsFor: 'adding'!