DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Create And Set Instance Variables From Method Parameters / Arguments

10.09.2009
| 4063 views |
  • submit to reddit
        Inserted at the top of the method body, this line creates instance variables for each of the method parameters and sets them to their respective argument values.
local_variables.each { |v| eval("@#{v}=eval(v)") }