implicit class RightApply[A](x: A) {
def :::[B](f: A => B): B = f(x)
}
val log: Any => Unit =
=> println(s"${new java.util.Date} - ${x}")
x
::: 6 * 7 log
This file is literate Scala, and can be run using Codedown:
$ curl https://earldouglas.com/posts/type-classes/rapply.md |
codedown scala | xargs -0 scala -nc -e
Fri Mar 08 09:43:38 MST 2019 - 42