!isEmpty
with nonEmpty
SC-R1017Standard Scala structures provide with both isEmpty
and nonEmpty
methods. Thefore, replacing !isEmpty
with nonEmpty
makes the code slightly more readable and easier to comprehend.
if (!list.isEmpty) {
// do something
}
if (list.nonEmpty) {
// do something
}