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

bug(ex4.5): slice with length 0 will yield wrong results, and capacity 0 will cause the program to panic #38

Open
zino23 opened this issue May 31, 2022 · 0 comments

Comments

@zino23
Copy link

zino23 commented May 31, 2022

  • When len(s) is 0, unique will return s[:1], which is not correct
  • When cap(s) is 0, the program will panic because of slice out of bounds error
zino23 pushed a commit to zino23/gopl that referenced this issue May 31, 2022
When the slice's length is 0, should directly return to prevent false
result or slice out of bounds runtime error
@zino23 zino23 changed the title ex4.5: slice with length 0 will yield wrong results, and capacity 0 will cause the program to panic bug(ex4.5): slice with length 0 will yield wrong results, and capacity 0 will cause the program to panic Jun 4, 2022
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

1 participant