Henry
Henry

Reputation: 101

Kotlin: How to simplify this filter firstNorNull call chain?

I got a warning from Android Studio: Call chain on collection type may be simplified.

val hit = hits.filter {
        val trackable = it.trackable
        trackable is Plane && trackable.isPoseInPolygon(it.hitPose)
    }.firstOrNull() ?: return

Upvotes: 4

Views: 1313

Answers (1)

Henry
Henry

Reputation: 101

list.firstOrNull { condition }

Upvotes: 4

Related Questions