Return-Path: X-Original-To: apmail-groovy-users-archive@minotaur.apache.org Delivered-To: apmail-groovy-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EA9CB18887 for ; Mon, 8 Feb 2016 14:12:05 +0000 (UTC) Received: (qmail 43457 invoked by uid 500); 8 Feb 2016 14:12:05 -0000 Delivered-To: apmail-groovy-users-archive@groovy.apache.org Received: (qmail 43422 invoked by uid 500); 8 Feb 2016 14:12:05 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 43412 invoked by uid 99); 8 Feb 2016 14:12:05 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Feb 2016 14:12:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 08F9EC02A4 for ; Mon, 8 Feb 2016 14:12:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.928 X-Spam-Level: X-Spam-Status: No, score=0.928 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, KAM_LAZY_DOMAIN_SECURITY=1, KAM_NOCONFIDENCE=0.5, RCVD_IN_DNSWL_MED=-2.3, RP_MATCHES_RCVD=-0.272] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id oau-wDHlj7hV for ; Mon, 8 Feb 2016 14:12:03 +0000 (UTC) Received: from mx7.det.nsw.edu.au (mx7.det.nsw.edu.au [153.107.165.13]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 2910C2050D for ; Mon, 8 Feb 2016 14:12:02 +0000 (UTC) Received: from PW0991EXMM0103.central.det.win (extmaildc.det.nsw.edu.au [153.107.164.251]) by mx7.det.nsw.edu.au (8.14.4/8.14.4) with ESMTP id u18EBtEb008715 for ; Tue, 9 Feb 2016 01:11:55 +1100 Received: from PW0991EX13M201.UC.DET.NSW.EDU.AU (Not Verified[10.7.40.19]) by PW0991EXMM0103.central.det.win with MailMarshal (v7,2,3,6978) id ; Tue, 09 Feb 2016 01:11:55 +1100 Received: from PW0991EX13M304.UC.DET.NSW.EDU.AU (10.7.40.29) by PW0991EX13M201.UC.DET.NSW.EDU.AU (10.7.40.19) with Microsoft SMTP Server (TLS) id 15.0.1130.7; Tue, 9 Feb 2016 01:11:55 +1100 Received: from PW0991EX13M305.UC.DET.NSW.EDU.AU (10.7.40.28) by PW0991EX13M304.UC.DET.NSW.EDU.AU (10.7.40.29) with Microsoft SMTP Server (TLS) id 15.0.1130.7; Tue, 9 Feb 2016 01:11:48 +1100 Received: from PW0991EX13M305.UC.DET.NSW.EDU.AU ([fe80::6cff:3f63:8180:2a16]) by PW0991EX13M305.UC.DET.NSW.EDU.AU ([fe80::6cff:3f63:8180:2a16%15]) with mapi id 15.00.1130.005; Tue, 9 Feb 2016 01:11:48 +1100 From: "Strachan, Paul" To: "users@groovy.apache.org" Subject: not sure about Collection.intersect Thread-Topic: not sure about Collection.intersect Thread-Index: AdFidQpJeHkJpUcgS/OGwOb40QmIdg== Date: Mon, 8 Feb 2016 14:11:48 +0000 Message-ID: <54abf962c593423f94149c8d1f5983e6@PW0991EX13M305.UC.DET.NSW.EDU.AU> Accept-Language: en-AU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.7.40.232] Content-Type: multipart/alternative; boundary="_000_54abf962c593423f94149c8d1f5983e6PW0991EX13M305UCDETNSWE_" MIME-Version: 1.0 --_000_54abf962c593423f94149c8d1f5983e6PW0991EX13M305UCDETNSWE_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Groovy 2.4.4 / 2.4.5 Hi - I'd like to get a list of objects from collection A that exist in co= llection B using intersect() but I'm getting no results: def c1 =3D []// as Set def c2 =3D []// as Set c1 << new TestClass(name: 'mike') c2 << new TestClass(name: 'mike') println c1.contains(c2[0]) assert c1.intersect(c2).size() =3D=3D 1 Output: true Assertion failed: assert c1.intersect(c2).size() =3D=3D 1 =20 | | | | | =20 | [] | 0 false =20 | [sample.TestClass@333357] =20 [sample.TestClass@333357] TestClass.groovy package sample import groovy.transform.EqualsAndHashCode @EqualsAndHashCode(includes =3D 'name') class TestClass { =20 String name } Is intersect only for simple types? ********************************************************************** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ********************************************************************** --_000_54abf962c593423f94149c8d1f5983e6PW0991EX13M305UCDETNSWE_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =

Groovy 2.4.4 / 2.4.5

 

Hi – I’d like to get a list of objects= =20from collection A that exist in collection B using intersect() but I&#= 8217;m getting no results:

 

def c1 =3D=
=20[]// as Set
def = c2 =3D []// as Set
c1 << new TestClass(= name: 'mike')
c2 <<
new TestClass(name: 'mike')
println c1.contains(c2[
<= span style=3D"font-size:9.0pt;color:blue">0
])
assert c= 1.intersect(c2).size() =3D=3D 1
 
 

Output:

 

true

Assertion failed:

 

assert c1.intersect(c2).size() =3D=3D 1

       |  | &n= bsp;       |   |   = ;   |

       |  [] &= nbsp;      |   0   &nbs= p;  false

       |  &nbs= p;         [sample.TestClass@3333= 57]

       [sample.TestClass= @333357]

 

 

TestClass.groovy

 

package sa=
mple
import gro=
ovy.transform.EqualsAndHashCode
@EqualsAndHashCode
(includes =3D 'name')

class TestClass {
    String
n= ame
}

 

 

Is intersect only for simple types?

=

 

 


******************************************************************= ****
This=20 message is intended for the addressee named and may contain
privilege= d=20 information or confidential information or both. If you
are not the i= ntended=20 recipient please delete it and notify the=20 sender.
**************************************************************= ********=20

--_000_54abf962c593423f94149c8d1f5983e6PW0991EX13M305UCDETNSWE_--