Sunday, August 6

A little knowledge can be dangerous

<arturaz> any ideas how i can get @foo from :foo ?

<inono> magic

<TeflonTed> eval "@#{:foo.to_s}" ? :-)

<arturaz> eval's evil :)

<TeflonTed> magic is evil

2 comments:

Anonymous said...

If you have attr_readers defined you can just do (from within the instance)

send(:foo)

El Raichu said...

Object#instance_variable_get

Object#instance_variable_set