Skip to content

Instantly share code, notes, and snippets.

@ryochin
Created November 4, 2015 11:57
Show Gist options
  • Save ryochin/30efcb9461560eb6a409 to your computer and use it in GitHub Desktop.
Save ryochin/30efcb9461560eb6a409 to your computer and use it in GitHub Desktop.
the pipeline operator like F#, OCaml, Elixir
package myproject
/*
via http://codereview.stackexchange.com/questions/26707/pipeline-operator-in-scala
usage:
import myproject.operator.pipeline
val f = (x: Int) => x * 2
5 |> f |> f
*/
object operator {
implicit class pipeline[F](val value: F) extends AnyVal {
def |>[G](f: F => G) = f(value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment