From: Harry Kakueki Date: 2009-10-26T15:32:03+09:00 Subject: Re: Array#collect in a method call, not working for me On Mon, Oct 26, 2009 at 1:19 PM, Michael Randall 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