On Thu, Oct 03, 2002 at 04:43:24AM +0900, Rotfeast wrote:
> At the risk of sounding like a nuby to ruby...
> 
> I know in Python, I can print the contents of the array
> [[1,2,3],[4,5,6],[7,8,9]] on the screen by using nested loops and "\n"
> statements.  I can make it appear as 3 rows of 3 elements, like a
> matrix.  I tried doing this in Ruby using analogous syntax:
> 
> [0..2].each do |i|
>     [0..2].each do |j|
>         print $a[i][j]
>     end
> print "\n"
> end
> 
> My output is 123456789--not what I'm looking for.  Any thoughts?
> 
How about

[[1,2,3],[4,5,6],[7,8,9]].each { |arr| puts arr.join(',') }
  
-- 
Alan Chen
Digikata LLC
http://digikata.com