I am sure I’m making a newbie mistake, as I’ve just started learning
Ruby, and would really appreciate someone pointing out what I’ve done
wrong, why it is wrong, and how it should be done. Thanks in advance.
I am writing a method definition to double any number, or all numbers if
an array of numbers is passed to it. When I use array.collect outside of
the method, it works as expected. When I place it inside of the method,
instead of multiplying each integer, it treats the entire array as one
object and double it, [1, 2, 3, 4] becoming 12341234.
I’ve attached my test code, “simplea.rb”, and below is the output when I
run it. In case it matters to anyone, I’m running Ruby 1.8.7 under
Cygwin (because I hate windows and don’t have a Mac yet).
Test double([1, 2, 3, 4])
Test double( 3 )
Let’s prove it.