1

So I tried to declare this simple case class

case class Association(id: Option[Long], type: String, name: String, description: Option[String], uri: URI, additonalInfo: String){

}

but it does not compile with this message:

- identifier expected but    'type' found.

It is of course because "type" is a reserved Scala keyword. I thought for some reasons that I can resolve this by providing a 'type (Symbol) instead but it still does not compile.

So how I can really label my parameter as a "type"? Please do not disappoint me telling this cannot be done in Scala :)

4

1 回答 1

5

只需使用粗引号:

case class Association(id: Option[Long], `type`: String, name: String, description: Option[String], uri: URI, additonalInfo: String)
于 2013-11-03T12:12:26.927 回答