F# has the pipeline operators:
arg |> func // or arg2 |> func arg1, as opposed to func arg1 arg2
func <| arg
Haskell has the $
operator:
func $ arg -- or func1 $ func2 arg, as opposed to func1 (func2 arg)
They're mostly used to increase readability by de-cluttering the function calls.
Is there a similar operator in Scala?
There is not. You can easily define your own, however.
implicit class PipeEverything[A](val underlying: A) extends AnyVal {
def |>[B](f: A => B) = f(underlying)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With