Logo

Programming-Idioms

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

Idiom #288 Check if set contains a value

Set the boolean b to true if the set x contains the element e, false otherwise.

_, b := x[e]

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

x has type map[E]bool
b = x.find(e) != x.end();

New implementation...