First page Back Continue Last page Overview Graphics
Ruby Gotchas
There is no automatic conversion of strings to numbers, as there is in Perl and awk. On the plus side, the operators for strings and numbers are consistent, unlike Perl.
In most cases, variables serve as references. Modifications to an object that has been assigned to two different variables will be reflected by both.
false and nil are the only values treated as false in conditionals. Everything else (including 0) is true!
- ruby -e 'printf "0 is %s\n", 0 ? "true" : "false"'
- perl -e 'printf "0 is %s\n", 0 ? "true" : "false"'