开发者

From Java, how can I access a var defined in a Scala trait?

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 = _
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜