I need to perform a null/empty check on some code, before performing some logic.
I have item below, because I feel !members?.empty
is not correct.
Is there a groovier way to write the following?
if (members && !members.empty) {
// Some Work
}
There is indeed a Groovier Way.
if(members){
//Some work
}
does everything if members
is a collection. Null check as well as empty check (Empty collections are coerced to false
). Hail Groovy Truth. :)