2

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?

1 Answer 1

6

You can use backticks to overcome the issue of reserved words:

override def `type` = { ... }

See: Scala Interoperability FAQs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.