groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Søren Berg Glasius (GR8Conf EU)" <sbglas...@gr8conf.org>
Subject Re: Check if List is of specific size and elements of specific type
Date Tue, 29 Mar 2016 10:29:25 GMT
Hi Maarten,

You could be close with this.

def listVariable = [1,2]
assert listVariable*.getClass() == [int, int]

but your assert will have to be

assert listVariable*.getClass() == [Integer, Integer]

since ints are actually the object type Integer

Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: Maarten Boekhold <boekhold@gmx.com>
Reply: users@groovy.apache.org <users@groovy.apache.org>
Date: March 29, 2016 at 12:25:42
To: users@groovy.incubator.apache.org <users@groovy.incubator.apache.org>
Subject:  Check if List is of specific size and elements of specific type  

Hi,  

Is there a quick and easy way to do something like:  

assert listVariable == [int, int]  

eg, the list is of size 2 and each element is an int?  

Maarten  

Mime
View raw message