Skip to content

Instantly share code, notes, and snippets.

@ahoy-jon
Created February 12, 2013 19:42
Show Gist options
  • Save ahoy-jon/4772737 to your computer and use it in GitHub Desktop.
Save ahoy-jon/4772737 to your computer and use it in GitHub Desktop.
trait Closable[A] {
def closable(a:A):Unit
}
object Ahoy extends App {
implicit def closable[A <: {def close:Unit}] = new Closable[A] {
def closable(a:A) {a.close}
}
def close[T:Closable](c:T) = {
implicitly[Closable[T]].closable(c)
}
case class Ahoy(plouf:String) {
def close {
println("--->" + plouf)
}
}
close(Ahoy("_____"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment