Search code examples
scalaplayframeworkplayframework-2.0

How to declare a variable named 'type' in Play/Scala?


I want to declare a variable with name 'type' in a Play/Scala application, since my data has this field name and I'm using JSON transforms. It just makes more sense.

Fortunately I could just rename the field, but still curious if there is a way to make the compiler ignore the type reserved word when declaring variables.


Solution

  • Use backticks:

    var `type` = 42