Skip to content

Instantly share code, notes, and snippets.

@takezoe
Created December 17, 2011 16:30
Show Gist options
  • Save takezoe/1490649 to your computer and use it in GitHub Desktop.
Save takezoe/1490649 to your computer and use it in GitHub Desktop.
Configure an instance by the given function
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