意外的$ end,期待keyword_end

时间:2013-05-18 00:30:08

标签: ruby

我正在使用问题here中的代码。我收到以下错误,

Example test : example1 - RUNTIME ERROR (tested program terminated unexpectedly)
Output:
user.rb:113: syntax error, unexpected $end, expecting keyword_end

example2 - RUNTIME ERROR (tested program terminated unexpectedly)
Output:
user.rb:113: syntax error, unexpected $end, expecting keyword_end

example_grouped - RUNTIME ERROR (tested program terminated unexpectedly)
Output:
user.rb:113: syntax error, unexpected $end, expecting keyword_end

以下是代码,

def check_triangle (_array)
  for p in 0 .. _array.length-1
    for q in p .. _array.length-1
      for r in q .. _array.length-1
        return true if _array[p] + _array[q] > _array[r] && _array[p] + _array[r] > _array[q] && _array[r] + _array[q] > _array[p]
      end
    end
  end

  return false
end

1 个答案:

答案 0 :(得分:4)

unexpected $end, expecting keyword_end

这意味着解析器在查找关键字$end时到达文件末尾(end)。换句话说,您错过了end,可能是class的{​​{1}}。您还没有发布足够的代码来确定。