From: James Edward Gray II Date: 2006-03-17T03:03:10+09:00 Subject: Re: build 3x3 table from one array On Mar 16, 2006, at 11:29 AM, forest wrote: > I am stuck trying to figure out how to take an array of data and > dynamically build a 3x3 html table from it without standard for loops. Here's one idea: >> data = (1..9).to_a => [1, 2, 3, 4, 5, 6, 7, 8, 9] >> require "enumerator" => true >> puts ""
=> nil >> data.each_slice(3) do |row| ?> puts " " >> row.each { |cell| puts " " } >> puts " " >> end => nil >> puts "
#{cell}
1 2 3
4 5 6
7 8 9
" => nil Hope that helps. James Edward Gray II