Created
February 12, 2013 19:42
-
-
Save ahoy-jon/4772737 to your computer and use it in GitHub Desktop.
This file contains 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
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