我有一个哈希,包括:
flow = ["a", "b", "c"]
h = [{"case_id"=>1, "a"=>{"x"=>"text", "option"=>"..." },"b"=>{"report"=>"text", "option"=>"..." } ,"c"=>{"y"=>"text", "option"=>"..." }},{"case_id"=>2, "a"=>{"x"=>"text", "option"=>"..." },"b"=>{"report"=>"text", "option"=>"..." } ,"c"=>{"y"=>"text", "option"=>"..." }}]
@case = 0
@report = ""
flow.each do |step|
if h[@case][step]['report']
@report = h[@case][step]['report']
end
end
控制台给了我以下错误:
NoMethodError in MainController#index
undefined method `[]' for nil:NilClass
为什么?!在以前的程序中,但使用 ruby 187,没有问题。但是现在,用ruby 193,给出了这个错误。