我正在使用问题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
答案 0 :(得分:4)
unexpected $end, expecting keyword_end
这意味着解析器在查找关键字$end
时到达文件末尾(end
)。换句话说,您错过了end
,可能是class
的{{1}}。您还没有发布足够的代码来确定。