I have to make a exception part on triangles now.
The exercise looks like this :
**# You need to write the triangle method in the file 'triangle.rb'
class AboutTriangleProject2 < EdgeCase::Koan
# The first assignment did not talk about how to handle errors.
# Let's handle that part now.
assert_raise(TriangleError) do triangle(0, 0, 0) end
assert_raise(TriangleError) do triangle(3, 4, -5) end
assert_raise(TriangleError) do triangle(1, 1, 3) end
assert_raise(TriangleError) do triangle(2, 4, 2) end
# HINT: for tips, see
So I looked at that page and come with this solution :
def triangle(a, b, c)
raise TriangleError, "length cannnot be 0 or lesser" if (a <= 0) or (b <=
0) or (c <= 0);
raise TriangleError, "length does not mach Pyschotorogas" if (a * a + b *
b != c * c);
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))
But now I get a uninitialized constant TriangleError
What did I do wrong now ?
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to firstname.lastname@example.org.
To unsubscribe from this group, send email to email@example.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/gpwo2gOeHJ0J.
For more options, visit https://groups.google.com/groups/opt_out.