私はグーグルを試みて、stackoverflowを見て、まだそれがうまくいかない理由を理解できませんでした。基本的に、このコード行は、命令のラインを通じてfile.txtをループで読み込むテキストファイルのNoMethodError:nilのための未定義メソッド `+ ':NilClass
# Load instruction in an array
File.open('file.txt').each do |line|
line_num += 1
array.to_a.push line.split(" ")
end
# Loop through the array of Instructions
array.each do |line|
instruction = line[0]
value = line[1].to_i
これは、私はあなたがあなたの変数を初期化する必要が
NoMethodError: undefined method `+' for nil:NilClass
method block in <main> in VirtualMemory.rb at line 3
method each in VirtualMemory.rb at line 2
method <main> in VirtualMemory.rb at line 2