Permalink
Browse files

got rubyplus to work for arrays, strings, and numbers.

  • Loading branch information...
1 parent a006033 commit f0fe2f74dad9eef45804908b9cdf41feb6cb8cfd @mattknox mattknox committed Apr 29, 2010
Showing with 4 additions and 7 deletions.
  1. +4 −7 js/primitives.js
View
@@ -1,14 +1,11 @@
-function puts(string) { print(string);};
+var sys = require('sys')
+function puts(string) { sys.puts(string);};
-function add(a,b) {
- return a + b;
-}
/* these should eventually do ruby-style case dispatch, and should be replaced
with calls to naked js primitives when possible. */
Number.prototype.rubyplus = function(a) { return a + this; };
+Object.prototype.rubyplus = function(a) { return this.concat(a); };
+String.prototype.rubyplus = function(a) { return this + a; };
Number.prototype.rubyminus = function(a) { return a - this; };
Object.prototype.rubytruthy = function (x) { return (x == null || x === false) ? false : x; };
-print(3);
-print('foo');
-

0 comments on commit f0fe2f7

Please sign in to comment.