Robert Klemme wrote:
> On 27.03.2008 16:28, Trans wrote:
...
>> I don't quite get matz take. How is
>>
>>    variables.each do |key, value|
>>      instance_variable_set("@#{key}", value)
>>    end
>>
>> cleaner than
>>
>>     instance_variable_set(variables)
> 
> How often is that really needed?  I can remember only few cases where I 
> needed that - and those were probably more experimental.

I've got a couple of methods in library code I use frequently that 
initialize or populate an object from a hash using the loop above. I've 
always thought it was kind of a pain (and inefficient) to have to 
construct a string for each key.

Why couldn't #instance_variable_set be agnostic about whether you refer 
to ivars as "foo" or "@foo" ? I don't see any ambiguity...

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407