Logo

Programming-Idioms

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

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.

x.delete(e)

If e is absent, this returns x.
x.delete?(e) would return nil if e is not present.
(disj x e)

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

New implementation...