编译时出现此错误:
Compilation error: reassignment to val
Run Code Online (Sandbox Code Playgroud)
我认为这看起来很明显,但在查看我的代码时,我无法找到为什么这不起作用.
以下是我的ConferenceController.scala中发生错误的代码示例:
def createConfWithPrivacy(confId: Long, groupId: Option[Long]) = ForcedAuthentication
{implicit request =>
Future {
val user = request.user.get
var newConf = Conference.findById(confId).get
if(groupId.isDefined){
newConf.forGroup = LabGroup.findById(groupId.get) <- there it is
Conference.updateForGroup(newConf)
}
...
}
}
Run Code Online (Sandbox Code Playgroud)
Conference.scala中的变量声明如下:
case class Conference (
id : Long,
title : String,
abstr : String,
speaker : Speaker,
startDate : DateTime,
length : Duration,
organizedBy: Lab,
location : Location,
accepted : Boolean,
acceptCode : Option[String],
priv : Boolean,
forGroup : …Run Code Online (Sandbox Code Playgroud) scala ×1