On 12.06.2007 15:12, Daniel Liebig wrote: > Daniel Liebig wrote: >> Farrel Lifson wrote: >> >>> On 12/06/07, Daniel Liebig <daniel.liebig / wevin.de> wrote: >> [..] >>> def assign_parmas(params) >>> params.each {|key,variable| instance_variable_set("@{key}",value)} >>> end >> >> >> Thank you both! >> >> Do you know if instance_variable_set() behaves different or is more >> performant in any way than eval()? Eval does not accidentally rhyme on evil. There are serious security implications of using eval - sometimes the interpreter may actually prevent evaling a string. Btw the solution with instance_eval walways works but you might not get at those values unless you also have attr accessors defined. Here's something else that you can do: irb(main):001:0> require 'ostruct' => true irb(main):002:0> o=OpenStruct.new(:foo=>1, :bar=>2) => #<OpenStruct foo=1, bar=2> irb(main):003:0> o.foo => 1 irb(main):004:0> o.bar => 2 I.e. use OpenStruct. You could as well leave parameters in the Hash... Kind regards robert