almays posted to #ruby:

almays

how to get the value of the @attribute by the attribute's name given as a :symbol?

1 year, 3 months ago.

2 comments so far

  • raydnoper

    Let @attr be "012345" ; ss = :attr ===> eval("@"+ss.to_s) voila :)

    1 year, 2 months ago by raydnoper.

  • entropie

    arg, Let.

    instancevariableget('@attr') # => "012345"

    1 year, 1 month ago by entropie.

Sign in to add a comment