Ishan Joshi
Ishan Joshi

Reputation: 31

How in operator works in Groovy?

I want to check for multiple string comparison in groovy. For example:

if (cityName in ('AHD','BLR','DEL'))
{

}

But, using this way, it is giving syntax error.

Upvotes: 0

Views: 295

Answers (1)

Opal
Opal

Reputation: 84756

To define in-place collection use [] instead of ():

if (cityName in ['AHD','BLR','DEL']) {

}

Anyway, in is used correctly.

Upvotes: 2

Related Questions