Do you guys know if there's any particular reason ...
# announcements
l
Do you guys know if there's any particular reason for
Char.isDigit
to not have it's opposite
Char.isNotDigit
?
a
maybe because we can do a !Char.isDigit ?
🤦‍♂️ 1
🤔 2
l
We always can
As we can with
String.isEmpty
, but we have a
String.isNotEmpty
But as I observed, it's usual to have a negated version of booleans in the STDLib
👆 1
l
#C0B8Q383C
s
Negated predicates are of course nice for filtering (
listOfStrings.filter(String::isNotEmpty)
is slightly more readable than
listOfStrings.filter {!it.isEmpty()}
) but also pollutes the API a little bit (double functions). So I guess you'd create one of those is it is used "often".