Groovy not in collection

前端 未结 8 1166
Happy的楠姐
Happy的楠姐 2021-02-04 23:50

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

8条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 00:20

    According to Grails documentation about creating criteria here, you can use something like this:

    not {'in'("age",[18..65])}
    

    In this example, you have a property named "age" and you want to get rows that are NOT between 18 and 65. Of course, the [18..65] part can be substituted with any list of values or range you need.

提交回复
热议问题