How to check if element in groovy array/hash/collection/list?

banderson623 picture banderson623 · Sep 9, 2008 · Viewed 226.5k times · Source

How do I figure out if an array contains an element? I thought there might be something like [1, 2, 3].includes(1) which would evaluate as true.

Answer

dahernan picture dahernan · Sep 15, 2008

Some syntax sugar

1 in [1,2,3]