Skip to content

Instantly share code, notes, and snippets.

@clhodapp
Created March 28, 2012 21:02
Show Gist options
  • Save clhodapp/2230472 to your computer and use it in GitHub Desktop.
Save clhodapp/2230472 to your computer and use it in GitHub Desktop.
Implicit Scope
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