From: Ryan Davis Date: 2007-06-22T16:54:29+09:00 Subject: Re: eval going boom On Jun 20, 2007, at 17:19 , Giles Bowkett wrote: > Object X is going to be an exact clone of Object Y, but it's a member > of a different class. > > This does not work: > > x.attributes.each {|attr, value| eval("y.#{attr}= #{value}")} >> p x.class => CommandsIShouldNeverEval >> p x.attributes => { :z => "`rm -rf /`" } >> x.attributes.each {|attr, value| eval("y.#{attr}= #{value}")} ... Don't use eval. There is no need in this example. CHALLENGE: rewrite the above code to not use eval at all. For that matter, don't even use #send.