Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Path Dependent types example
// First a simple example of Tuple creation
val myTuple2 = ("A", 1)
val myTuple3 = ("B", 2, true) // creates a Tuple3 of String, Int, Boolean
// Not on to the path dep types stuff
trait BaseTrait {
type T
val baseA : T
}
class ChildA[String](param : String) extends BaseTrait {
type T = String
override val baseA = param
println(baseA)
}
val childA = new ChildA("A")
type B = String
class ChildB[String](param : String) extends BaseTrait {
// type T = B // Won't compile - baseA (below) has an incompatible type !
// type T = childA.T // Won't compile - baseA (below) has an incompatible type !
type T = String
override val baseA = param
println(baseA)
}
val childB = new ChildB("B")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.