首页 > 其他 > 详细

Groovy学习笔记-布尔求值

时间:2017-07-27 15:34:33      阅读:274      评论:0      收藏:0      [点我收藏+]

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

 

Groovy学习笔记-布尔求值

原文:http://www.cnblogs.com/ironcrow/p/7244895.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!