Ruby Koan 151 raising exceptions

后端 未结 30 1598
孤独总比滥情好
孤独总比滥情好 2021-01-31 14:34

I\'m going through the ruby koans, I\'m on 151 and I just hit a brick wall.

Here is the koan:

# You need to write the triangle method in the file \'trian         


        
30条回答
  •  梦毁少年i
    2021-01-31 15:22

    You have to check that the new created triangle don't break the "Triangle inequality". You can ensure this by this little formula.

    if !((a-b).abs < c && c < a + b)
      raise TriangleError
    end
    

    When you get the Error:

     exception expected but none was thrown.
    

    Your code is probably throwing an exception while creating a regular triangle in this file. about_triangle_project.rb

提交回复
热议问题