On Apr 8, 2007, at 10:10 PM, Matt Hulse wrote:
> Comments are welcome, I'm here to learn!
Some things I saw while reading through your code:
* print "...\n" is just puts "..." in Ruby.
* Ruby has a command-line switch to enable a debuggin mode: -d.
Among other things, this sets $DEBUG to true. So instead of
commenting out print statements, just do something like:
puts ... if $DEBUG
You can then run with ruby -d ... when you want the output.
* You can swap values without a temporary variable in Ruby: array
[a], array[b] = array[b], array[a].
* When you set something and then go into an iterator to modify it,
you probably want inject() instead: (2..n).inject { |fac, n| fac * n }.
* The Ruby naming convention is to use snake_case for variables and
methods.
The above are just some suggestions. The code seems to work, which
is the most important part. Nice work.
James Edward Gray II