Skip to content

Instantly share code, notes, and snippets.

@bluescreen303
Created July 17, 2009 14:49
Show Gist options
  • Save bluescreen303/149088 to your computer and use it in GitHub Desktop.
Save bluescreen303/149088 to your computer and use it in GitHub Desktop.
RubyArray = new JS.Class({
include: JS.Enumerable,
initialize: function(ary) {
this._ary = ary;
},
forEach: function(block, context) {
if (!block) return this.enumFor('forEach');
for (var i = 0, n = this._ary.length; i < n; i++)
block.call(context || null, this._ary[i]);
return this;
},
// plus Array-specific methods
});
var a = new RubyArray([1,2,3,5])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment