I have just started looking at Kotlin, I have been using F# on .NET for a while now and I am liking Kotlin. I am missing pipe operator in Kotlin though, is there any plan to bring the pipe operator to Kotlin?
m
marstran
04/06/2021, 9:41 AM
Why do you need the pipe operator? It may be idiomatic F#, but it's not idiomatic Kotlin. Doesn't extension functions and method-call-chaining kind of solve the same problem?
marstran
04/06/2021, 9:42 AM
Like, instead of this in a language with the pipe-operator:
Copy code
list |> map f1 |> flatMap f2
You would just do
list.map(f1).flatMap(f2)
.
g
gildor
04/06/2021, 10:34 AM
There are no plans as I know, and there is no proposal for this
gildor
04/06/2021, 10:36 AM
Maybe you could show some example of typical usage which you missed in Kotlin, I'm really curious how different it is comparing to F#
e
elizarov
04/06/2021, 11:19 AM
Kotlin has two features that mike piping much less needed:
1. Kotlin has extensions, which usually let you "pipe" things directly in a natural
.call
style, e.g.
collection.filter {...}.map{...}
(no need for a pipe here)
2. Kotlin has
.let
scope function that covers the case for non-extension functions, e.g.