Scala: "val" as an identifier is possible? Linking to java library needs it

In my scala code, I use a java library that 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?

+6
source share
1 answer

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

 val foo = new XYZ foo.`val` 

See the Scala Compatibility FAQ .

+12
source

All Articles