Form helpers-style get instance variable from a symbol

Does anyone know what Ruby magic functions you use to turn a Symbol like
:purchase into a valid instance variable @purchase?

Hi –

On Sun, 20 Aug 2006, Bryan D. wrote:

Does anyone know what Ruby magic functions you use to turn a Symbol like
:purchase into a valid instance variable @purchase?

sym = :purchase
value = “whatever”

instance_variable_set(“@#{sym}”, value)

@purchase is now “whatever”

David


http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack’s][ Web]log
Ruby for Rails => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.