Logo

Programming-Idioms

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

Idiom #276 Insert an element in a set

Insert an element e into the set x.

x[e] = struct{}{}

x has type map[E]struct{}
x[e] = true

x has type map[E]bool
#include <set>
x.insert(e);

New implementation...