小编Cal*_*aom的帖子

意外错误:重新分配给val

编译时出现此错误:

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

0
推荐指数
1
解决办法
3771
查看次数

标签 统计

scala ×1