Reputation: 7655
I have a java interface with a method declared like this String type();
. I want to implement it in a scala class, so I would like to write:
override def type = { ... }
But apparently its a reserved keyword in scala, so the compiler is complaining:
identifier expected but 'type' found.
How is it possible to implement it? Is there a solution without having to change the Java interface?
Upvotes: 2
Views: 237
Reputation: 159864
You can use backticks to overcome the issue of reserved words:
override def `type` = { ... }
See: Scala Interoperability FAQs
Upvotes: 6