Last active
April 21, 2021 00:32
-
-
Save diasandre/42db29f7c7ef1fda551e0099498f079e to your computer and use it in GitHub Desktop.
arrow-kt partial method reference using partially1 and curried
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arrow.core.curried | |
import arrow.core.partially1 | |
fun main() { | |
val application = Application() | |
val value = "value" | |
val usePartially1 = value | |
.let((application::functionWith2parameters::partially1)("first")) | |
println(usePartially1) //first-value | |
val useCurriedWith2Parameter = value | |
.let((application::functionWith2parameters.curried())("first")) | |
println(useCurriedWith2Parameter) //first-value | |
val useCurriedWith3Parameter = value | |
.let((application::functionWith3parameters.curried())("first")("second")) | |
println(useCurriedWith3Parameter) //first-second-value | |
} | |
class Application { | |
fun functionWith2parameters(first: String, value: String) = "$first-$value" | |
fun functionWith3parameters(first: String, second: String, value: String) = "$first-$second-$value" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment