From: Regis d'Aubarede Date: 2010-09-30T23:48:50+09:00 Subject: Re: The beauty of Ruby through examples 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/.