Write your own isNumeric in any language! | December 20th, 2007
I found this interesting article today. I was looking for an isNumeric equivilent in ruby and discovered someone had cobbled together the equivilent in every language he could think of:
http://www.rosettacode.org/rosettacode/w/index.php?title=IsNumeric
January 8th, 2008 at 7:52 pm
By the way.. the best one for Ruby (if your value is a string) is:
String.prototype.isNumeric = function() { return (this.match(/^d+$/) !=
null); }
January 16th, 2008 at 11:19 pm
Actually, Rosetta Code is a wiki I founded almost a year ago. The IsNumeric page consists of contributions by almost two dozen individuals.
Glad you found it interesting. Currently, though, a little less than half of the 121 tasks on the site have had Ruby solutions contributed.
January 17th, 2008 at 2:27 pm
That’s surprising. Hopefully more Ruby types will pick it up. Nice project, Michael.