I want to do something similar to this: class Foo @goo = 2 @boo = 5 end foo = Foo.new ["goo", "boo"].each do |attribute| puts foo.attribute # should print out 2 on the first loop, 5 on the second loop end Ideas?