我想出了以下解决方案的公仔。为什么这不起作用 - 红宝石koans
# and
# about_triangle_project_2.rb
#
def triangle(a, b, c)
driehoek = Array.new[ a, b, c].sort
raise (TriangleError), "length cannnot be 0 or lesser" if (driehoek[0] <= 0)
raise (TriangleError), "impossible triangle" if (driehoek[0] + driehoek[1] < driehoek[2])
return :equilateral if ((a == b) and (b == c))
return :isosceles if (((a == b) and (b != c)) or
((a != b) and (b == c)) or
((a == c) and (a != b)))
return :scalene if ((a !=b) and (b != c))
end
# Error class used in part 2. No need to change this code.
class TriangleError < StandardError
end
但现在当三角[2,2,2]使用我看到此错误消息:
The answers you seek...
wrong number of arguments (3 for 2)
Please meditate on the following code:
./triangle.rb:18:in `[]'
./triangle.rb:18:in `triangle'
谁能告诉我这里有什么问题?
Roelof
响应指向一个错误。请下次指出代码中的第#18行。你也不需要提供整个代码,只有与questin – UncleGene