Skip to content

give sets a usable zero value#80

Draft
KevinJoiner wants to merge 1 commit intomainfrom
zero-value-sets
Draft

give sets a usable zero value#80
KevinJoiner wants to merge 1 commit intomainfrom
zero-value-sets

Conversation

@KevinJoiner
Copy link
Contributor

Proposed Changes

I don't need this change just curious on thoughts
Make the zero value useful.
https://go-proverbs.github.io/

@KevinJoiner KevinJoiner requested a review from a team as a code owner August 19, 2024 13:35
@KevinJoiner KevinJoiner marked this pull request as draft August 19, 2024 13:36
@elffjs
Copy link
Member

elffjs commented Aug 19, 2024

I think at this point we wrap in a struct and get some visibility/clarity benefits. What do you think?

@elffjs
Copy link
Member

elffjs commented Aug 24, 2024

Here’s my problem with stuff like this I think. I think people for better or worse expect map-like behavior from sets. But here if you do

func main() {
	var s Set[string]
	addXpp(s)
	fmt.Println(s)
}

func addXpp(s Set) {
	s.Add("xpp")
}

That Add call is not visible to the caller.

https://go.dev/play/p/RWWUM26wfbx

Copy link
Member

@JamesReate JamesReate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like it

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 this pull request may close these issues.

3 participants