Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumKotlinhigher-order function compositionSingle-choice MCQ

What is the type and behavior of `combined` below, where `::isPositive` and `::isEven` are referenced via a generic combinator?

fun <T> and(p1: (T) -> Boolean, p2: (T) -> Boolean): (T) -> Boolean = { p1(it) && p2(it) } val isPositive: (Int) -> Boolean = { it > 0 } val isEven: (Int) -> Boolean = { it % 2 == 0 } val combined = and(isPositive, isEven) val r = combined(-4)