Hello,
Why not to have an iterator over the hash like
Hash.each_pair(function(key, value){...});
as a shortcut for
Hash.each(function(pair){
var id = pair.key, obj = pair.value;
});
The point is that if one makes heavy use of hashes in code, this small
redundancies get really annoying. Why both
Hi,
I doubt it'll make core, but there's no reason you can't do that for
your own stuff:
* * * *
Hash.addMethods({
eachPair: function(iterator, context) {
return this.each(function(pair, index) {
iterator.call(context, pair.key, pair.value, index);
});
}
});
*