Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Go

Idiom #277 Remove an element from a set

Remove the element e from the set x.

Explains what happens if e was already absent from x.

delete(x, e)

x has type map[E]struct{}

If x is nil or there is no such element, delete is a no-op.
delete(x, e)

x has type map[E]bool

If x is nil or there is no such element, delete is a no-op.
(disj x e)

Removing a non-existent element from a set returns back an identical set.

New implementation...