I am new to ruby and still haven't got my mind around iterators although
I think they are really cool.
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 is the code in JavaScript:
var MAX_ROW = 3;
var MAX_COL = 3;
var nIdx = 0;
print("<table>");
for (var r = 0; nIdx < aList.length && r < MAX_ROW; r++)
{
print("<tr>");
for (var c = 0; nIdx < aList.length && c < MAX_COL; c++)
{
print("<td>");
print(aList[nIdx].name);
nIdx++;
print("</td>");
} // cols
print("</tr>");
} // rows
print("</table>");
Can someone point me in the right direction for how to do this. I found
each_index but still was at a loss.
Thanks for the help.
forest
--
Posted via http://www.ruby-forum.com/.