Skip to content

Instantly share code, notes, and snippets.

@jamesgolick
Created November 24, 2009 00:00
Show Gist options
  • Select an option

  • Save jamesgolick/241496 to your computer and use it in GitHub Desktop.

Select an option

Save jamesgolick/241496 to your computer and use it in GitHub Desktop.
object Tappable {
implicit def any2Tappable[A](toTap: A): Tappable[A] = new Tappable(toTap)
}
class Tappable[A](toTap: A) {
def tap(block: (A) => Unit): A = { block(toTap); toTap }
}
scala> import Tappable._
import Tappable._
scala> "tapped".tap { (s) => println(s) }
tapped
res3: java.lang.String = tapped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment