不用抛异常
def foo(str) {
//if (str != null) { str.reverse() }
str?.reverse()
}
println foo('evil')
println foo(null)
异常不需要catch捕获
不用抛异常
def foo(str) {
//if (str != null) { str.reverse() }
str?.reverse()
}
println foo('evil')
println foo(null)
异常不需要catch捕获