i think this extension function should be part of ...
# announcements
c
i think this extension function should be part of Kotlin fun <T> List<T>.exists(predicate: (T) -> Boolean): Boolean { return this.firstOrNull(predicate) != null } to do things like this someList.filterNot { p -> anotherList.exists { e -> e.anotherId == t.someId } }
g
Is this somehow different from existing
any
extension?
anotherList.any { it.anotherId == t.someId }
c
missed 'any' function, yes this is what i'm looking for, thanks
what i did not understand is why the function is named exactly
any
if it checks for the existence of an element in the list
should don't it be named
exists
?
r
Returns true if any element matches the predicate
👍 1
g
it means ” is there any element in this collection that matches the predicate”
yeah, Rob was faster 🔫
there is also counterpart:
none
c
ok thanks
r
and
all