Right-Associative Function Application

Implementation

implicit class RightApply[A](x: A) {
  def :::[B](f: A => B): B = f(x)
}

Example

val log: Any => Unit =
  x => println(s"${new java.util.Date} - ${x}")

log ::: 6 * 7

Demo

This file is literate Scala, and can be run using Codedown:

$ curl https://earldouglas.com/type-classes/rapply.md |
  codedown scala | xargs -0 scala -nc -e
Fri Mar 08 09:43:38 MST 2019 - 42

References