Kroppeb
05/09/2020, 5:23 PM(Entity)->Boolean
to just a Function1<Entity, Boolean>
and not to something that doesn't require boxing like `Predicate<Entity`>?Jakub Pi
05/09/2020, 6:23 PMPredicate<Entity>
with the implied Boolean
return.Kroppeb
05/09/2020, 6:23 PMJakub Pi
05/09/2020, 6:24 PMtypealias Predicate<T> = (T) -> Boolean
Kroppeb
05/09/2020, 6:24 PMJakub Pi
05/09/2020, 6:26 PMKroppeb
05/09/2020, 6:27 PMelizarov
05/09/2020, 8:07 PMFunctionXxx
interfaces to be included into the Kotlin standard library for all the combinations of pritimite types and still it would have been impossible to include all of them, but only a small subset. Better be pretictable here. In cases where you care avout boxing you can always define your own interface:
interface Predicate<T> {
operator fun invoke(t: T): Boolean
}
However, I highly recommend to carefully measure the performance benefit of any such change in your code first. It actually helps much less often than it might seem to.Jakub Pi
05/09/2020, 8:21 PM