From: Jim Weirich Date: 2004-01-19T21:46:39+09:00 Subject: Re: setting instance variable "dynamically" gabriele renzi wrote: > you may even use instance_eval("@a="+value.to_s) Be aware that this only works when "value" has valid string representation that can be reliably converted back to an object. And then you only get a copy, not the original object. The following will work with arbitrary objects ... obj.instance_eval("lambda { |v| @a = v }").call(value) At this point you must be thinking: "Why don't I just use instance_variable_set?" -- -- Jim Weirich jweirich@one.net http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)