6

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?

Heinzi
  • 5,793
  • 4
  • 40
  • 69

1 Answers1

12

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.

Randall Schulz
  • 26,420
  • 4
  • 61
  • 81
ach
  • 6,164
  • 1
  • 25
  • 28