-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pages 316 and 317 - Sorting #52
Comments
I've moved the big comment and added a couple of new comments to clarify the code. The final else still needs to return 0 though to indicate that when both objects are null, they are equal. |
That final else will never be reached though the way you have it set up. If other is not null it goes into the first if. Then you have an 'else if (other is null)', but we already know it is null since it didn't go into the 1st if, and it will always go into the 2nd and never reach the final else. So, you can just make the 2nd an else instead and set position to -1 there. |
You already have an entry for this in the errata, but I don't think that is correct. The branch you marked as not being able to be reached can be reached if there are multiple null names, see example below:
I think the below branch can never be reached though:
The above can be replaced by:
The text was updated successfully, but these errors were encountered: