标签:学习笔记 groov color 学习 output 布尔 集合 logs 判断
1.判断字符串为null或空字符串
def str = null if(str) println ‘str is not null‘ else println ‘str is null‘ str = ‘‘ if(str) println ‘str is not null‘ else println ‘str is null‘ /*output str is null str is null */
2.集合是否为空或Count ==0
list = null if(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
标签:学习笔记 groov color 学习 output 布尔 集合 logs 判断
原文地址:http://www.cnblogs.com/ironcrow/p/7244895.html