Created
March 28, 2012 21:02
-
-
Save clhodapp/2230472 to your computer and use it in GitHub Desktop.
Implicit Scope
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
package P { | |
class A(val v: Int) | |
class B(val v: Int) | |
class C { | |
def getV(x: B) = x.v | |
} | |
} | |
package object P { | |
implicit def a2b(x: A) = new B(x.v) | |
} | |
object Do extends App { | |
val a = new P.A(3) | |
val c = new P.C | |
println(c.getV(a)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment