I have to create a class that in its definition contains a variable named 'type', for example like this:
case class testEntity (
type: String,
val: String
)
Is there any possible to do that?
CodePudding user response:
To use names that are normally not allowed you have to put them in backticks (`). Your declaration will look like this:
case class testEntity (
`type`: String,
`val`: String
)
Since type
and val
are both keywords.
EDIT: Also the convention in Scala is to start class names with a capital letter.