tan shai
tan shai

Reputation: 3

scala reserved keywords match

I am importing in a Scala project a java class which uses the keyword match . I need to override the method match in my Scala code.

class Foo extends JavaClass {

      override def match (String str) : Boolean = { .... }}

But this is not working, the error is:

identifier expected but 'match' found

What is the problem?

Upvotes: 0

Views: 457

Answers (2)

airudah
airudah

Reputation: 1179

match is a reserved word so you're not allowed to modify it. You just have to call it something else.

Perhaps def `match`(str: String)...

Upvotes: 2

Simon
Simon

Reputation: 6363

Try this

override def `match` (str: String) : Boolean = { .... }}

Upvotes: 1

Related Questions