Java – unexpected tags in kotlin (use; separate expressions on the same line)

I use kotlin in my android project, which is developed on Java. I use kotlin data classes in the service layer

Now I want to add an alternate tag to the sequence

@SerializedName(value="name",alternate={"person","user"}) val title:String,

This gave me an unexpected token problem, which seems to come from the kotlin side

This seems to be the kotlin problem. Someone can point out my problem

Solution

I think this will complete the work:

@SerializedName(value="name",alternate=arrayOf("person","user")) val title:String

The kotlin compiler treats alternate = {"person", "user"} as function type

Edited on 1brustone:

In kotlin 1.2, array literals can be used, but only for comments:

@SerializedName(value = "name",alternate = ["person","user"]) val title:String
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>