RosettaCodeData/Task/Dynamic-variable-names/Ruby/dynamic-variable-names.rb

5 lines
128 B
Ruby
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
p "Enter a variable name"
2015-02-20 00:35:01 -05:00
x = "@" + gets.chomp!
instance_variable_set x, 42
p "The value of #{x} is #{instance_variable_get x}"