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

Set.Difference

Overview

Difference returns elements in a but not in 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 Difference[T comparable](a, b Set[T]) Set[T]

Compare: Node.js · Standard Go · gox

js
// Typical Set pattern in Node.js
go
// Iterate maps/sets manually
go
import "github.com/sahilkhaire/gox/set"

set := set.New("alpha", "beta")
set.Difference(value, b)

Example

go
import "github.com/sahilkhaire/gox/set"

set := set.New("alpha", "beta")
set.Difference(value, b)

Tips

Obtain a Set value first (see constructors on the package overview), then call Difference.

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