Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
Index: /Users/jan/webdev/moodev/mootools/trunk/Native/String.js =================================================================== --- /Users/jan/webdev/moodev/mootools/trunk/Native/String.js (revision 715) +++ /Users/jan/webdev/moodev/mootools/trunk/Native/String.js (working copy) @@ -38,6 +38,9 @@ /* Property: toInt parses a string to an integer. + + Arguments: + base - Integer, optional; base to use, defaults to 10 Returns: either an int or "NaN" if the string is not a number. @@ -46,8 +49,8 @@ >var value = "10px".toInt(); // value is 10 */ - toInt: function(){ - return parseInt(this, 10); + toInt: function(base){ + return parseInt(this, base || 10); }, /* Index: /Users/jan/webdev/moodev/mootools/trunk/Native/Number.js =================================================================== --- /Users/jan/webdev/moodev/mootools/trunk/Native/Number.js (revision 715) +++ /Users/jan/webdev/moodev/mootools/trunk/Native/Number.js (working copy) @@ -16,10 +16,17 @@ /* Property: toInt Returns this number; useful because toInt must work on both Strings and Numbers. + + Arguments: + base - Integer, optional; base to use, defaults to 10 + + Example: + (111).toInt() // returns 111 + (111).toInt(2); // returns 7 */ - toInt: function(){ - return parseInt(this); + toInt: function(base){ + return parseInt(this, base || 10); }, /*
From the Design Piracy series on my blog: