def printTree(tree,indent)
 if (Array === tree)
     tree.map { |child| printTree(child,indent+"|  ") }
 else
     puts(indent.gsub(/\s+$/,"--")+tree.to_s)
 end
end
printTree([1,2,[11,22,[111,222,333,444],33],3,4],"")


this give :
 |--1
 |--2
 |  |--11
 |  |--22
 |  |  |--111
 |  |  |--222
 |  |  |--333
 |  |  |--444
 |  |--33
 |--3
 |--4
-- 
Posted via http://www.ruby-forum.com/.