Set.Union
Overview
Union returns elements in a or b.
Part of the set package — Node.js analog: Set.
Method on Set — call it on a value of that type after constructing or receiving one from a constructor.
Signature
go
func Union[T comparable](a, b Set[T]) Set[T]Compare: Node.js · Standard Go · gox
js
new Set([...a, ...b]);go
// Iterate maps/sets manuallygo
import "github.com/sahilkhaire/gox/set"
u := set.Union(a, b)Example
go
import "github.com/sahilkhaire/gox/set"
u := set.Union(a, b)Tips
Obtain a Set value first (see constructors on the package overview), then call Union.
Standard library alternative
gox wraps the Go standard library or a trusted dependency with Node-familiar naming. You can use the underlying library directly — see the package overview for escape hatches.