Skip to content

Instantly share code, notes, and snippets.

@jakedouglas
Created November 5, 2008 18:39
Show Gist options
  • Save jakedouglas/22395 to your computer and use it in GitHub Desktop.
Save jakedouglas/22395 to your computer and use it in GitHub Desktop.
irb(main):001:0> @foo = "abc"
=> "abc"
irb(main):002:0> @bar = "def"
=> "def"
irb(main):003:0> @baz = "ghi"
=> "ghi"
irb(main):004:0> ["foo", "bar", "baz"].each do |var|
irb(main):005:1* puts "Hi my name is " + var + " and my value is " + instance_variable_get("@#{var}")
irb(main):006:1> end
Hi my name is foo and my value is abc
Hi my name is bar and my value is def
Hi my name is baz and my value is ghi
=> ["foo", "bar", "baz"]
irb(main):007:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment