From: David Tran Date: 2005-01-18T08:22:21+09:00 Subject: Re: [SOLUTION] Ruby Quiz #15 Animal Quiz 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 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 > -- David Tran http://www.doublegifts.com