Is there anyway to convert a string to an instance varible? eg. Suppose I have @name defined. Is there any method that would return @name given the string "name" ? Also, is there a similar method for local variables? Thanks in advance, Thushan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Thushan a écrit :> Is there anyway to convert a string to an instance varible? >Yes there is. Just try instance_variable_get("@name") and you''ll have the value of @name. You should read the documentation of the Object class for more information :) http://www.ruby-doc.org/core/classes/Object.html Cheers, -- ,= ,-_-. =. Loïc Guitaut ((_/)o o(\_)) http://www.belfalas.org `-''(. .)`-'' Jabber ID : Flink-z1Ll2v8wZ5tg9hUCZPvPmw@public.gmane.org \_/ GnuPG KeyID : 0xA78CD85D
Thanks Loïc. instance_variable_get and instance_variable_set worked for me. What about local variables? / Thushan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---