So again, as I said in the previous post: So to answer the main question: “Why we should use functional programming with Kotlin?” They could be use to simplify building complex functionality. print ()Īny of this examples will have the same qualities that we talk about before, small blocks that connect things, that can be unit tested and No pipe functions, change our normal functions into extensions: fun Type. ![]() Who need pipes? just connect things with normal Kotlin I can understand that this whole operators things is not for everyone, neither to use for everything so we have one So now we could use them like this: 12545 pipe Do :: reverse and Do :: print "dlrow olleh" pipe Do :: reverse and Do :: print 12545 pipe Do :: square and Do :: text and Do :: reverse and Do :: print To simplify the code it will start from where we end in the previous post, with this Java class: static class Wrapper Note : I’m not an expert in Kotlin and probably many things that I do here are not how you should code it, this is just for demonstration porpoises. ![]() Learn Kotlin, I like to update my previous entry with examples written in Kotlin.Īnd as before, this is not going to be about qualities, neither comparison with Java, this is about code, to show how we could solve solutions with it.Īll the code posted here is available in this git repo and you could follow the tests incrementally to understand this concepts. Recently I made a post about why we should use functional programming, but since I’m trying now to
0 Comments
Leave a Reply. |