Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Alexander Campbell
10,533 PointsWhy do we not need to use int(other) in comparisons?
When we write:
return int(self) == other
I see this as comparing an instance of int to an instance of Die, which doesn't make sense. How is other automatically being converted to an int? Shouldn't it be:
return int(self) == int(other)
??
2 Answers
Todd Anderson
4,260 PointsUsing == is checking to make sure both are the same. If you say int(self) == other, that should already be checking that other is an int.
Todd Anderson
4,260 Points:)
Alexander Campbell
10,533 PointsAlexander Campbell
10,533 PointsOhhh, I think I misunderstood what the comparison was from the start - we ARE comparing a
Dieto anint