Skip to content

Instantly share code, notes, and snippets.

@tobnee
Created May 7, 2015 14:16
Show Gist options
  • Save tobnee/63429a2ba8da9cfd625f to your computer and use it in GitHub Desktop.
Save tobnee/63429a2ba8da9cfd625f to your computer and use it in GitHub Desktop.
Trait to function pimping
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