|
@@ -1796,12 +1796,11 @@ category: 'instance creation',
|
|
|
fn: function (aCollection){
|
|
|
var self=this;
|
|
|
var newCollection;
|
|
|
-function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
|
|
|
return smalltalk.withContext(function($ctx1) {
|
|
|
var $1,$2;
|
|
|
$1=_st(_st(aCollection)._size())._even();
|
|
|
if(! smalltalk.assert($1)){
|
|
|
-_st($Error())._signal_("#newFromPairs only accepts arrays of an even length");
|
|
|
+_st(self)._error_("#newFromPairs only accepts arrays of an even length");
|
|
|
};
|
|
|
newCollection=_st(self)._new();
|
|
|
_st(_st((1))._to_by_(_st(aCollection)._size(),(2)))._do_((function(keyIndex){
|
|
@@ -1812,9 +1811,9 @@ $2=newCollection;
|
|
|
return $2;
|
|
|
}, function($ctx1) {$ctx1.fill(self,"newFromPairs:",{aCollection:aCollection,newCollection:newCollection},smalltalk.HashedCollection.klass)})},
|
|
|
args: ["aCollection"],
|
|
|
-source: "newFromPairs: aCollection\x0a\x22Accept an array of elements where every two elements form an association - the odd element being the key, and the even element the value.\x22\x0a| newCollection |\x0aaCollection size even ifFalse: [ Error signal: '#newFromPairs only accepts arrays of an even length' ].\x0anewCollection := self new.\x0a( 1 to: aCollection size by: 2 ) do: [ :keyIndex | newCollection at: ( aCollection at: keyIndex ) put: ( aCollection at: keyIndex + 1 ) ].\x0a^ newCollection.",
|
|
|
-messageSends: ["ifFalse:", "signal:", "even", "size", "new", "do:", "at:put:", "at:", "+", "to:by:"],
|
|
|
-referencedClasses: ["Error"]
|
|
|
+source: "newFromPairs: aCollection\x0a\x22Accept an array of elements where every two elements form an association - the odd element being the key, and the even element the value.\x22\x0a| newCollection |\x0aaCollection size even ifFalse: [ self error: '#newFromPairs only accepts arrays of an even length' ].\x0anewCollection := self new.\x0a( 1 to: aCollection size by: 2 ) do: [ :keyIndex | newCollection at: ( aCollection at: keyIndex ) put: ( aCollection at: keyIndex + 1 ) ].\x0a^ newCollection.",
|
|
|
+messageSends: ["ifFalse:", "error:", "even", "size", "new", "do:", "at:put:", "at:", "+", "to:by:"],
|
|
|
+referencedClasses: []
|
|
|
}),
|
|
|
smalltalk.HashedCollection.klass);
|
|
|
|