Suppose I have following trait and object:
trait T {
val x: Int
println("In Trait", x)
}
object Obj extends T{
val y: Int = 10
val x: Int = y
def run() = {
println("In Obj", x)
}
}
Obj.run()
// (In Trait,0)
// (In Obj,10)
Can I have the value of x
from trait T
be the same as the value of x
in object Obj
? In other words, my expected output should be:
// (In Trait,10)
// (In Obj,10)
Assume that value of y
is known only at runtime.