is there a cleaner way to do this? ` fun isVali...
# codingconventions
l
is there a cleaner way to do this?
fun isValid(): Boolean = noteText.isNotEmpty() && noteText.isNotBlank() && noteText.length > 3
to avoid repeating noteText several times? thanks
b
if you’re just trying to get rid of
noteText
from being repeated, there’s always
Copy code
noteText.run {
    isNotEmpty() && isNotBlank() && length > 3
}
👍 1
k
Doesn't
isNotBlank
imply
isNotEmpty
?
s
yes, it does
isNotEmpty()
is literally
length > 0
, so it makes no sense to have a length check as well anyway
b
yeah. That
trim()
solution is as literal in a single expression as it gets
k
trim()
is allocating which is suboptimal