Ruby Koan 151 raising exceptions

后端 未结 30 1555
孤独总比滥情好
孤独总比滥情好 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条回答
  •  囚心锁ツ
    2021-01-31 15:05

    For the Koan about_triangle_project_2.rb there's no need to change TriangleError class. Insert this code before your triangle algorithm to pass all tests:

    if ((a<=0 || b<=0 || c<=0))
        raise TriangleError
    end
    
    if ((a+b<=c) || (b+c<=a) || (a+c<=b))
        raise TriangleError
    end
    

提交回复
热议问题