Set.Intersection
Overview
Intersection returns elements in both a and 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 Intersection[T comparable](a, b Set[T]) Set[T]Compare: Node.js · Standard Go · gox
js
// Typical Set pattern in Node.jsgo
// Iterate maps/sets manuallygo
import "github.com/sahilkhaire/gox/set"
set := set.New("alpha", "beta")
set.Intersection(value, b)Example
go
import "github.com/sahilkhaire/gox/set"
set := set.New("alpha", "beta")
set.Intersection(value, b)Tips
Obtain a Set value first (see constructors on the package overview), then call Intersection.
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.