Skip to content

Instantly share code, notes, and snippets.

@kmizu
Created May 15, 2010 08:58
Show Gist options
  • Save kmizu/402104 to your computer and use it in GitHub Desktop.
Save kmizu/402104 to your computer and use it in GitHub Desktop.
object ImplicitRunnable {
//こっちのバージョンはまぎらわしいかも
//implicit def any2Runnable(block: => Any): Runnable = new Runnable {
// def run { block }
//}
implicit def fun2Runnable(block: () => Any): Runnable = new Runnable {
def run { block() }
}
def main(args: Array[String]) {
//使用例
new Thread(() => for(i <- 1 to 10) println(i)).start()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment