On Tue, 12 Dec 2006, Paul Lutus wrote:

> chen li wrote:
>
>> Hi Paul,
>>
>> Thank you so much for your time and input.
>>
>> I just need to print  a 2D array to screen in the
>> following format:
>>
>> [
>>  [1,2,3,4,5,6,7,8,9,10,11,12],
>>  [13,14,15,16,17,18,19,20,21,22,23,24],
>> ..
>>  [85,86,87,88,89,90,91,92,93,94,95,96]]
>>
>>
>>
>> After I create a 2D array of 8 row x12 column 2D from
>> a 1D array I want to print this format directly to the
>> screen without writing further code lines. If the
>> column number is less than 10 I can print the
>> data(using pp) in the format above but if column
>> number is 12 I can't. To solve this the only thing I
>> can do is to write another loop(see below) to go
>> through to the same 2D again.
>>
>> _2D_array.each{|i| puts i}
>
> Problem: The library 'pp' cannot produce the result you want.
>
> Solution: don't use 'pp'. Instead, write an additional line of code.

Yes it can.  See Eric Hodel's reply and my replies, and see pp.rb.


David

-- 
Q. What's a good holiday present for the serious Rails developer?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    aka The Ruby book for Rails developers!
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)