Created
May 7, 2015 14:16
-
-
Save tobnee/63429a2ba8da9cfd625f to your computer and use it in GitHub Desktop.
Trait to function pimping
This file contains 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
trait X { def execute() } | |
implicit class XtoFunction(val x: X) extends Function0[Unit] { | |
def apply() = x.execute() | |
} | |
val g = new X{ def execute() = println("foo") } | |
g() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment