|
|
|
|
|
by valenterry
2055 days ago
|
|
Ah, I understand what you mean now. You are looking indeed for the thrush operator. I think it should be built into Scala's standard library, but until that happens, you can use the mouse library or build it yourself. Here is an example: // Need to define this once somewhere in your project
implicit class TrushExtension[A](anything: A) {
def |>[B](function: A => B) = function(anything)
}
// Your application code
def fun(arr: Iterable[Int]) = arr.map(_.toDouble / Math.PI)
val arr = 0 to 100
val newArr = arr.map(_*2) |> fun
newArr.foreach(println) // prints 0, 0.63662, 1.27324, ...
Execute or change the code here: https://scalafiddle.io/sf/WAKhZtJ/0This is maybe not exactly as convenient, but it comes pretty close. "someA.someB.someC" becomes "someA |> someB |> someC". |
|