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

[{'answer_id': 51951, 'author': 'banderson623', 'author_id': 5419, 'author_profile': 'https://Stackoverflow.com/users/5419', 'pm_score': 6, 'selected': False, 'text': '<p>For lists, use <code>contains</code>:</p>\n\n<pre><code>[1,2,3].contains(1) == true\n</code></pre>\n'}, {'answer_id': 62082, 'author': 'dahernan', 'author_id': 6435, 'author_profile': 'https://Stackoverflow.com/users/6435', 'pm_score': 8, 'selected': False, 'text': '<p>Some syntax sugar</p>\n\n<pre><code>1 in [1,2,3]\n</code></pre>\n'}, {'answer_id': 66753, 'author': 'shemnon', 'author_id': 8020, 'author_profile': 'https://Stackoverflow.com/users/8020', 'pm_score': 8, 'selected': True, 'text': "<p>.contains() is the best method for lists, but for maps you will need to use .containsKey() or .containsValue()</p>\n\n<pre><code>[a:1,b:2,c:3].containsValue(3)\n[a:1,b:2,c:3].containsKey('a')\n</code></pre>\n"}, {'answer_id': 163883, 'author': 'John Flinchbaugh', 'author_id': 12591, 'author_profile': 'https://Stackoverflow.com/users/12591', 'pm_score': 3, 'selected': False, 'text': '<p>If you really want your includes method on an ArrayList, just add it:</p>\n\n<pre><code>ArrayList.metaClass.includes = { i -&gt; i in delegate }\n</code></pre>\n'}, {'answer_id': 27724859, 'author': 'Twelve24', 'author_id': 1513628, 'author_profile': 'https://Stackoverflow.com/users/1513628', 'pm_score': 2, 'selected': False, 'text': '<p>IMPORTANT Gotcha for using .contains() on a Collection of Objects, such as Domains.  If the Domain declaration contains a EqualsAndHashCode, or some other equals() implementation to determine if those Ojbects are equal, and you\'ve set it like this...</p>\n\n<pre><code>import groovy.transform.EqualsAndHashCode\n@EqualsAndHashCode(includes = "settingNameId, value")\n</code></pre>\n\n<p>then the .contains(myObjectToCompareTo) will evaluate the data in myObjectToCompareTo with the data for each Object instance in the Collection. So, if your equals method isn\'t up to snuff, as mine was not, you might see unexpected results.</p>\n'}, {'answer_id': 39934815, 'author': 'HinataXV', 'author_id': 6942112, 'author_profile': 'https://Stackoverflow.com/users/6942112', 'pm_score': 2, 'selected': False, 'text': '<pre><code>def fruitBag = ["orange","banana","coconut"]\ndef fruit = fruitBag.collect{item -&gt; item.contains(\'n\')}\n</code></pre>\n\n<p>I did it like this so it works if someone is looking for it.</p>\n'}, {'answer_id': 59853867, 'author': 'MagGGG', 'author_id': 1726413, 'author_profile': 'https://Stackoverflow.com/users/1726413', 'pm_score': 3, 'selected': False, 'text': '<p>You can use Membership operator:</p>\n\n<pre><code>def list = [\'Grace\',\'Rob\',\'Emmy\']\nassert (\'Emmy\' in list)  \n</code></pre>\n\n<p><a href="https://docs.groovy-lang.org/latest/html/documentation/#_membership_operator" rel="noreferrer">Membership operator Groovy</a></p>\n'}, {'answer_id': 62537459, 'author': 'ninj', 'author_id': 7760893, 'author_profile': 'https://Stackoverflow.com/users/7760893', 'pm_score': 0, 'selected': False, 'text': '<p>You can also use matches with regular expression like this:</p>\n<pre><code>boolean bool = List.matches(&quot;(?i).*SOME STRING HERE.*&quot;)\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/51927', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5419/']