Ruby Koan 151 raising exceptions

后端 未结 30 1590
孤独总比滥情好
孤独总比滥情好 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:07

    You could also try to instance the exception with:

    raise TriangleError.new("All sides must be greater than 0") if a * b * c <= 0
    

提交回复
热议问题