Skip to content
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

Open
rmantel23 opened this issue Jun 14, 2024 · 2 comments
Open

Pages 316 and 317 - Sorting #52

rmantel23 opened this issue Jun 14, 2024 · 2 comments

Comments

@rmantel23
Copy link

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:

image

image

I think the below branch can never be reached though:

image

The above can be replaced by:

image

@markjprice
Copy link
Owner

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.

@rmantel23
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants