I would like to create an extension function for a collection to check if one collection contains any item of defined set. I think about two implementations:
infix fun <T> Iterable<T>.containsAny(values: Iterable<T>): Boolean = any(values::contains)
or
infix fun <T> Iterable<T>.containsAny(values: Iterable<T>): Boolean = intersect(values).isNotEmpty()
The question is which way is more efficient and why? And is there any better solution?