There are no performance and memory issue, If you look at origin source code, the "dup" is only to duplicate array of 1 element. so either : @node[0,1] = [question, [animal], @node.dup] or @node[0,1] = [question, [animal], [@node[0]]] works, but not @node[0,1] = [question, [animal], @node] I try to make it better but it is unnecessary. Sorry again for my mistake. I am newbie on Ruby too. ;-) On Mon, 17 Jan 2005 18:22:14 -0500, David Tran <email55555 / gmail.com> wrote: > I try to avoid "dup" (and reuse the "pointer"), but the way I did is > not good, it creates recursive array. > So the changed code below is not good. Sorry for the confuse. > > BTW: My english is really poor; in my code, all the word "quest" > should read as "guess" instead. > > > On Mon, 17 Jan 2005 11:36:59 -0500, David Tran <email55555 / gmail.com> wrote: > > Quick review, find a performance and memory issue ... > > > > The code: > > if get_answer > > @node[0,1] = [question, [animal], @node.dup] > > else > > @node[0,1] = [question, @node.dup, [animal]] > > end > > > > is better replace by: > > temp = @node > > if get_answer > > @node[0,1] = [question, [animal], temp] > > else > > @node[0,1] = [question, temp, [animal]] > > end > > -- David Tran http://www.doublegifts.com