The groovy way to see if something is in a list is to use \"in\"
if(\'b\' in [\'a\',\'b\',\'c\'])
However how do you nicely see if something
You can add new functions:
Object.metaClass.notIn = { Object collection -> !(delegate in collection) } assert "2".notIn(['1', '2q', '3']) assert !"2".notIn(['1', '2', '3']) assert 2.notIn([1, 3]) assert !2.notIn([1, 2, 3]) assert 2.notIn([1: 'a', 3: 'b']) assert !2.notIn([1: 'a', 2: 'b'])