I have a trait that defines a single var and a single function like what follows:
trait MyTrait {
var myVar: Boolean
def m开发者_JS百科yFunction = 7
}
This trait is used by a class (let's say MyClass) and I'm using that class in a couple of Java files that I haven't converted yet. How, in my existing Java classes, can I access that variable? I can access the method just fine.
Figured it out in one last attempt. If you initialize myVar
it works as expected.
var myVar: Boolean = _
精彩评论