Binding

A special case of partial application is binding. With binding, you pass a T parameter to the (T) -> R function but without executing it, effectively returning an () -> R function:

fun main(args: Array<String>) {

val footer:(String) -> String = {content -> "<footer&gt;$content</footer>"}
val fixFooter: () -> String = footer.bind("Functional Kotlin - 2018") //alias for partially1
println(fixFooter())
}

The function bind is just an alias for partially1, but it makes sense to have a separate name for it and make it more semantically correct.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.144.248