On Mon, Oct 26, 2009 at 1:19 PM, Michael Randall <randallsata / gmail.com> wrote: > > 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. > Using code similar to yours....... You could try this or something like this. def double(n) [n].flatten.map {|num| num * 2 } end puts double([1, 2, 3, 4]) puts puts double(3) Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html