//<script>
/*

  Array obtains the each method similar to that in Ruby.

  Usage:
    array = new Array(1, 2, 3)
    array.each(function(value) {
      alert(value)
    });

*/

Object.prototype.each = function(f) {
  current = 0;
  while(current < this.length) {
    f(this[current++]);
  }
}

Object.prototype.each_pair = function(f) {
  for (key in this) {
    if (key == 'initialize') continue;
    if (key == 'each') continue;
    if (key == 'each_pair') continue;
    if (key == 'extend') continue;
    f(key, this[key]);
  }
}

//</script>
