Guy Decoux wrote:

> ruby is smarter than perl :-)
>
> Don't change it :-)

Also read, "ruby isn't quite as dumb as perl" ;-)

Seriously, Ruby's "to_i" isn't equivalent to Perl's "int" 
function.  "int" expects a numeric argument, so the string 
is automatically converted to a number (which might be a 
floating-point number), then "int" extracts the integer 
portion of that.  It's that automatic conversion process 
that isn't smart enough to handle hex, binary and octal 
numbers.  "to_i", on the other hand, _is_ the conversion 
process.  As such (and because it doesn't have to worry 
about floating-point conversions), it can be much more 
powerful.  In fact, if you could pass it an argument 
specifying the radix of the number, there would be no need 
for "oct" and "hex" at all.  Those two functions always 
bugged me in Perl, because they seem like they should be 
close equivalents, but they aren't.  Now, in Ruby, we have 
_three_ similar-looking methods that actually behave very 
differently.  C'mon, I thought Ruby was supposed to be an 
improvement over Perl!

--Alan