Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Scala have a function application operator?

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?

like image 848
Electric Coffee Avatar asked Mar 07 '14 09:03

Electric Coffee


Video Answer


1 Answers

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)
}
like image 195
Rex Kerr Avatar answered Sep 30 '22 07:09

Rex Kerr