title: Want to check if object is in groovy list using .contains() or 'in'
body: <pre><code>import groovy.transform.EqualsAndHashCode;
  @EqualsAndHashCode(includes="name")
  class Activity {
    public String name
    public buildings = []
    public rooms = [] as Set
  
    Activity(name) {
      this.name = name
    }
  }
  
  thisActivity=new Activity("activity")
  activityRegistry = []
  
  // is false correct
  activityRegistry.contains(thisActivity)
  
  // add new item activity2
  activityRegistry &lt;&lt; new Activity("activity2")
  
  // is true?????
  activityRegistry.contains(thisActivity)
  </code></pre>
  
  <p>this code is pretty straight forward, I create an activityRegistry list, I compare empty list to object I created. naturally test fails. I create a new object on the fly using new that I insert into the list. I compare the list then to the first object created, which is not part of the list, and contains, or in passes. could someone shed some light on how? or why?</p>