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

For conversion from starlight Set to native Go map use map[interface{}]struct{} #6

Open
deckarep opened this issue Dec 7, 2018 · 1 comment

Comments

@deckarep
Copy link

deckarep commented Dec 7, 2018

Since the empty struct is more compact.

@natefinch
Copy link
Collaborator

Yeah, I've gone back and forth... in real use, I don't think size really matters unless you're making a gigantic set... my main concern is usability, and plain bools are easier to work with than struct{}.

// this is easier and nicer
set["foo"] = true
exists := set["foo"] 
// this is more compact, but ugly
set["foo"] = struct{}{}
_, exists = set["foo"]

I'll keep this open for now to have other people weigh in on it, but I don't think it really matters either way.... and bool is slightly easier to read IMO.

chasehensel added a commit to chasehensel/starlight that referenced this issue Jul 6, 2020
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