Scala: Thrush combinator

i = 1
j = i + 1
k = j + 2
Seq(1,2,3)
.filter(_ % 2 == 0)
.map(_ * 2)
|>
object MyClass {
def echo(x: String) = println(x)
implicit class PipeEverything[A](val underlying: A) extends AnyVal {
def |>[B](f: A => B) = f(underlying)
}
def main(args: Array[String]) {
"Can you hear me?" |> echo
}
}
Can you hear me?
"Can you hear me?" |> echo

--

--

--

On a continuing learning journey..

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Connect a Private GitHub Repository with Google Colab via a Deploy Key

EC by Example: CountBy

Litepaper v1.0.

A Comprehensive Framework for Intrinsic OpenStreetMap Quality Analysis among Most Cited Paper in…

‘Self’ in Ruby

Statements That Change with Time

DB migration — an abstruse issue demystified

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Learn

Learn

On a continuing learning journey..

More from Medium

Scala: for-comprehension contexts do not mix

Type Classes in Scala 2

Polymorphic functions in Scala

[Scala] Implicit Parameters