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 trialTony Brackins
28,766 Pointsequals(other)
in the following code used in the video:
if (equals(other)) { return 0;
shouldn't it read:
if (something.equals(other)) { return 0;
??
2 Answers
Seth Kroger
56,413 PointsThere's an implicit 'this.' so: if (equals(other)) { return 0;
means: if (this.equals(other)) { return 0;
Because you call compareTo() from a Treet like this: aTreet.compareTo(otherTreet) 'aTreet' is 'this' inside the method.
prakashregmi
3,474 PointsI was confused in this part. Thanks Seth for elaborating the code.
Tony Brackins
28,766 PointsTony Brackins
28,766 Pointsmakes sense. thx!
Patrick Koch
40,496 PointsPatrick Koch
40,496 Pointsthx, cleaned things up!
Oziel Perez
61,321 PointsOziel Perez
61,321 PointsJust out of curiosity, can you literally write in "this.equals(other)" for clarification purposes? or is there another keyword? (or not?)