まず最初に、以下のイテレーションの外にある @market_0_home の割り当てを示します。
>> @market_0_home = 3
=> 3
OK、エラーはありません。少し複雑な繰り返しの中でこれを試してみましょう
>> markets
=> [{"home"=>"CO", "name"=>"David Douglas"}, {"home"=>"SC", "name"=>"David Robertson"}]
>> markets.each_with_index do |market, i|
?> market.each do |name, v|
?> instance_variable_set "market_#{i}_#{name}", v
>> end
>> end
NameError: `market_0_home' is not allowed as an instance variable name
from (irb):23:in `instance_variable_set'
from (irb):23
from (irb):22:in `each'
from (irb):22
from (irb):25:in `each_with_index'
from (irb):21:in `each'
from (irb):21:in `each_with_index'
from (irb):21
>>