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

slices.Compact #257

Closed
Deleplace opened this issue Sep 20, 2023 · 1 comment
Closed

slices.Compact #257

Deleplace opened this issue Sep 20, 2023 · 1 comment

Comments

@Deleplace
Copy link

Hello, while researching for this Go proposal I noticed this code:

slices.Compact(depProjectIDPendingQueue)

which probably doesn't behave as intended and should look like this instead:

depProjectIDPendingQueue = slices.Compact(depProjectIDPendingQueue)

I have not tried to execute it.

@comp500
Copy link
Member

comp500 commented Sep 23, 2023

Good catch, I think you are right from looking at how slices.Compact works - it would leave duplicate values at the end of the slice! This seems very counter-intuitive particularly as the documentation says Compact modifies the contents of the slice s; it does not create a new slice. and the similar slices.Sort function does not require this reassignment. I feel like it would be beneficial to also document this footgun in the slices documentation.

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