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 #2564

Closed
Deleplace opened this issue Sep 20, 2023 · 2 comments · Fixed by #2565
Closed

slices.Compact #2564

Deleplace opened this issue Sep 20, 2023 · 2 comments · Fixed by #2565

Comments

@Deleplace
Copy link

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

slices.Compact(labels)

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

labels = slices.Compact(labels)

I have not tried to execute it.

@tlimoncelli
Copy link
Contributor

Interestingly enough... there's no need to compact labels. The items in labels come from map keys, which are by definition unique.

That said... this is an opportunity to clean up some of the code. Thanks for pointing this out!

@Deleplace
Copy link
Author

You may consider golang.org/x/exp/maps.Keys, which is handy.

For other interesting reasons, map.Keys is not yet part of the stdlib.

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

Successfully merging a pull request may close this issue.

2 participants