let Connection.use() return a T

This commit is contained in:
James Strachan
2012-08-02 12:06:08 +01:00
parent 137eee3f45
commit 7eba9c3896
@@ -24,9 +24,9 @@ fun getConnection(url : String, user : String, password : String) : Connection =
/**
* Executes specified block with connection and close connection after this
*/
fun Connection.use(block : (Connection) -> Any?) : Unit {
fun <T> Connection.use(block : (Connection) -> T) : T {
try {
block(this)
return block(this)
} finally {
this.close()
}