Skip to content
Node: Setgithub.com/sahilkhaire/gox/set

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 manually
go
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.

Back to set package overview

MIT Licensed · Built for Node.js developers moving to Go