Robert Klemme
3/16/2006 9:25:00 AM
"rtilley" <rtilley@vt.edu> wrote in message
news:dv9hej$dnv$1@solaris.cc.vt.edu...
> rtilley wrote:
>> I like the way in which p prints out the contents of an array. It's easy
>> for me to read. Is it possible to make a method return p array? Or is
>> there a better way to do this?
>>
>> def info
>> #create an array
>> p array
>> return p array
>> end
>
> Just to clarify my question... When I create an array like this:
>
> x = Array.new
> x.push(1,2,3)
This can be shortened to
x=[1,2,3]
> And then write the array to a file, I get a file that reads 123. I would
> like a file that looks like this [1, 2, 3] instead.
Do x.inspect or x.join ", "
Kind regards
robert