Groovy code:
def line = "aa bb"
println line?.split("\\s+")?[1]
I want to use ? for an array to get an item. If the array is null, then return null, just like ?..
But the above code can’t be compiled. How to fix it? Or is there any other simple alternative solution to this?
You can use
getAtinstead of[](subscript operator)http://groovyconsole.appspot.com/script/801001