0

My script creates some variables like this:

instance_variable_set "@_#{pos}", dir

where pos is an integer. This gives me some instance variables @_1, @_2, @_3, etc. My script receives an argument (a number) from the command line, and that number needs to refer to an instance variable created like this:

puts $path.gsub(@_(pos), "")

For example, if ARGV[0] is 1, then I need to use var @_1 in a command like gsub like this:

puts $path.gsub(@_1, "")

How can I do this?

4

1 回答 1

2

Use instance_variable_get function: rubydoc

于 2012-11-13T10:50:17.967 回答