Created
November 24, 2009 00:00
-
-
Save jamesgolick/241496 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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