From: Robert Klemme Date: 2008-03-28T04:35:00+09:00 Subject: Re: instance_variable_[gs]et On 27.03.2008 16:28, Trans wrote: > > On Mar 27, 8:23 am, Florian Gilcher wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> On Mar 27, 2008, at 5:36 AM, Trans wrote: >> >> >> >>> And why can't #instance_variable_set take a hash to set more than one >>> variable at a time? >>> T. >> By the way, if you really need it, it is easily implemented on your own: >> Example: >> >> def set_instance_variables(variables) >> variables.each do |key, value| >> instance_variable_set("@#{key}", value) >> end >> end > > Yes, of course. Facets has #instance_assign, but it just seems > wasteful when one method could do. > > 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. Kind regards robert