[Proto-Scripty] hash iterator

2010-01-23 Thread Mikhail Kozhevnikov
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

[Proto-Scripty] Re: hash iterator

2010-01-23 Thread T.J. Crowder
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); }); } }); *