I'm just starting out with playFramework with the intention of speeding up web application development using my Java experience. Since Scala is apparently the most common option for views in the game, I decided to use it, despite the fact that it was new to it (and did not intend to delve into it, at least for now).
Well, I just realized that “type” is a reserved word in scala, and although I have seen other Q & As, is there a way to use the “type” word as a variable name in Scala? and How to use the Java package com.example ... in Scala , saying that I just need to add an attachment type using ``
However, when I use the template code below:
<dl>
@for(alarm <- alarms){
<dt>@alarm.id</dt>
<dd>@alarm.`type`</dd>@* type is a scala keyword, so I had to escape it *@
<dd>@form(routes.Application.deleteAlarm(alarm.id)) { <input type="submit" value="Delete"> }</dd>
}
</dl>
output:
models.Alarm@1. type
instead of type value.
How can I avoid the keyword in this case?
source
share