Created
December 17, 2011 16:30
-
-
Save takezoe/1490649 to your computer and use it in GitHub Desktop.
Configure an instance by the given function
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
class Configurable[T](value: T) { | |
def configure (func: T => Unit): T = { | |
func(value) | |
value | |
} | |
} | |
object Configurable { | |
implicit def any2configurable[T](value: T): Configurable[T] = new Configurable[T](value) | |
} | |
import Configurable._ | |
val conn = getConnection() configure { conn => | |
conn.setAutoCommit(true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment