문제

In my scala code, I'm using a java library which defines an object with a public attribute called "val":

public class XYZ {
    public int val=...
}

Is there a way to get this attribute in scala?

도움이 되었습니까?

해결책

You can use backticks. They remove the reserved status of any Scala keyword (or symbol).

val foo = new XYZ
foo.`val`

See the Scala Interoperability FAQ.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top