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

What is the type and behavior of `compose` here when chaining functions with different intermediate types?

infix fun <A, B, C> ((B) -> C).compose(g: (A) -> B): (A) -> C = { a -> this(g(a)) } val parse: (String) -> Int = { it.length } val describe: (Int) -> Boolean = { it > 3 } val pipeline = describe compose parse println(pipeline("hello"))