Displaying 1 result from an estimated 1 matches for "inst_var_name".
Did you mean:
ast_var_name
2005 Dec 22
2
Accessing an instance variable by its name (as a string)
...which gets passed the name of an instance variable,
and spits its out all nicely formatted.
Just wondering, how do i access the variable, when all i have is its
name stored as a string?
So far i''ve got this code, but it looks horrible. Is there a better way?
eval("@" << inst_var_name << "." << field_name << ".to_s")
--
Posted via http://www.ruby-forum.com/.