groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dinko Srkoč <dinko.sr...@gmail.com>
Subject Re: Check if List is of specific size and elements of specific type
Date Tue, 29 Mar 2016 12:13:53 GMT
On 29 March 2016 at 14:07, Søren Berg Glasius (GR8Conf EU)
<sbglasius@gr8conf.org> wrote:
> @dinko yeah, that's why I choose to do my example with
> listVariable*.getClass()

Yeah, I know. :-)

One needs to get burned once or twice in order to learn (one == me,
but I imagine I'm not alone ;-) ).

- Dinko

>
> 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: Dinko Srkoč <dinko.srkoc@gmail.com>
> Reply: users@groovy.apache.org <users@groovy.apache.org>
> Date: March 29, 2016 at 14:04:50
> To: users@groovy.apache.org <users@groovy.apache.org>
> Subject:  Re: Check if List is of specific size and elements of specific
> type
>
> On 29 March 2016 at 12:29, Marcos Carceles <marcos.carceles@gmail.com>
> wrote:
>> Would this work?
>>
>> listVariable*.class == [Integer, Integer]
>
> It would in this particular example, but this may be dangerous for
> some other cases. Try e.g. this:
>
> [1, [:], [class: 1]]*.class
>
> Cheers,
> Dinko
>
>>
>> On 29 March 2016 at 12:25, Maarten Boekhold <boekhold@gmx.com> wrote:
>>>
>>> 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