首页 > 代码库 > Groovy学习笔记-布尔求值

Groovy学习笔记-布尔求值

1.判断字符串为null或空字符串

def str = nullif(str)    println ‘str is not null‘else    println ‘str is null‘str = ‘‘if(str)    println ‘str is not null‘else    println ‘str is null‘/*outputstr is nullstr is null*/

2.集合是否为空或Count ==0

list = nullif(list)    println ‘list is not null‘else    println ‘list is null‘list = []if(list)    println ‘list is not null‘else    println ‘list is null‘/*output    list is null    list is null*/

3.集合新增元素

def list = [‘aaa‘];list<<‘a‘println list

 

Groovy学习笔记-布尔求值