ok, but yeah i think <@UB9K6R4JH> is right. My im...
# kotlintest
b
ok, but yeah i think @LeoColman is right. My impl ended up looking like:
Copy code
private inline fun <reified U> containInstanceOf(crossinline block: (U) -> Unit) = object : Matcher<Collection<*>> {
        override fun test(value: Collection<*>): MatcherResult {
            var foundInstance = false
            value.forEach {
                if (it is U) {
                    block(it)
                    foundInstance = true
                    return@forEach
                }
            }
            return MatcherResult(
                foundInstance,
                { "No instances of type ${U::class} found " },
                { "Instance of type ${U::class} found " }
            )
        }
    }

    private inline fun <reified U> Collection<*>.shouldContainInstanceOf(crossinline block: (U) -> Unit = {}) =
        this should containInstanceOf(block)