From: Mark Probert Date: 2002-10-30T04:23:18+09:00 Subject: problem with recursive structure Dear Rubists, I have a little class called SimpleTree that makes a recursive data structure of arrays. I am getting some funny behaviour when I traverse the tree for printing. The print routine is: def pp_branch(b) puts "(head) #{b[0]}" b.each { |item| next if item == b[0] # avoid the head pp_branch(item) if item.type == Array puts "(leaf) #{item}" } end Output looks like: ["a", "b", ["z/", "a", "b", ["y/", "c", "d"], "e"]] (leaf) a (leaf) b (head) z/ (leaf) a (leaf) b (head) y/ (leaf) c (leaf) d (leaf) y/cd (leaf) e It is the line "y/cd" that gets me. Ruby (or is it me?) appears to be flattening included array "y". Anyone help me with this? TIA, -mark ----- Mark Probert GNPS - Optera Metro 3000 Tel (613) 768-1082 (ESN: 398-1082) Mob (613) 715-2045 email: probertm@nortelnetworks.com