golang-set icon indicating copy to clipboard operation
golang-set copied to clipboard

What about adding a `set.Append(vals...T)` method to add multiple values to an existing set?

Open jeffwidman opened this issue 3 years ago • 1 comments

We've got NewSet(vals...T) for creating a set from multiple values.

But today I found myself wanting to add a slice of objects to an existing set... today I have to write a for loop to range over the objects.

What about adding an append(vals... T) method... similar to Python, which allows adding multiple objects.

Alternatively Add(val T) bool could be modified to take multiple args, which would keep the API surface small. But it's a little undefined that it returns a bool... for multiple objects would that return true if all the objects got added to the existing set, or if at least one object got added?

Thoughts?

jeffwidman avatar Apr 14 '22 06:04 jeffwidman

I definitely support having some improved ergonomics like an Append api call. Maybe we can leave Add as is and go with this?

Sounds like a plan.

deckarep avatar Apr 14 '22 17:04 deckarep