0

I am defining a class as:

@Index(name="idKey", fields=Array("name", "id"), type=IndexType.idkey)
class MyObj {
...
}

The library defining @Index is in Java, and it also defines IndexType. The example in Java reads:

@Index(name="indexOne",fields={"ssn","dob"},type=IndexType.idkey)
    public class Person {
    public String  name;
    public Date dob;
    public String  ssn;
}

I am getting "illegal start of simple expression" with an underline of "type" sin the @Index annotation. I assume I have a syntax error crossing the language, but I have tried using the IndexType enum in a method definition and I have tried re-ordering the parameters of @Index and removing the "type=" parameter and it seems like the error is in the phrase "type=IndexType.idkey", but I can't find an example of a similar usage that tells me what the error is.

Thank you.

Jonathan Card
  • 122
  • 1
  • 8
  • 2
    `type` is a keyword in Scala. Backticks might work – user Oct 15 '20 at 21:50
  • Brilliant. Thank you. Put it in as an answer and I'll upvote it. – Jonathan Card Oct 15 '20 at 22:06
  • 2
    Thanks, but there are already similar [questions](https://stackoverflow.com/questions/18042166/play-framework-illegal-start-of-simple-expression), and it probably wouldn't be too useful to future users. I'd just close this question as a duplicate if I were you – user Oct 15 '20 at 22:10
  • 1
    Well, if so I couldn't find it. If someone closes it, so be it. Thanks again. – Jonathan Card Oct 15 '20 at 22:21
  • This has been flagged as a duplicate, but none of the questions were duplicate questions; they merely had the same answer. – Jonathan Card Oct 16 '20 at 20:05
  • They're all basically the same issue - `type` is a keyword in Scala and people want to use it for some argument. What matters is that the answers there solve your question, not that they're exact duplicates of your question. – user Oct 16 '20 at 20:30

0 Answers0