about piping. is piping, with dedicated operators etc., required only in languages that don’t suppor...
m
about piping. is piping, with dedicated operators etc., required only in languages that don’t support extension functions? for example: F#
Copy code
let f = [ 1; 2; 3; 4; 5 ] |> List.map (fun x -> x * 2) |> List.map string
Kotlin
Copy code
fun f() = listOf(1, 2, 3, 4, 5).map { it * 2 }.map(Int::toString)
it’s much nicer looking in Kotlin because
map
is en extension function. same goes for
.let {}
,
.apply {}
etc.
p
Not necessarily required, just an alternative approach. One tradeoff is that
let { }
is much easier on the parser than pipe blocks, because you reuse the semantics of regular blocks
m
I have very limited set for comparison: F# and Kotlin so this is just what I observed from working in those two
p
Its a good observation, yes 😄
m
thanks 😄