I get this error when compiling:
Compilation error: reassignment to val
I think this seems obvious, but when looking at my code I can't find why this doesn't works.
Here is the sample of code where the error happens, from my 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)
}
...
}
}
The variables in Conference.scala are declared like following:
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 : Option[LabGroup]=None
) {... Functions ...}
The functions called is from the LabGroup.scala file, I know this one works:
def findById(id: Long): Option[LabGroup] = DB.withConnection { implicit c =>
SQL("SELECT * FROM LabGroup WHERE id = {id}")
.on("id" -> id)
.as(labGroupParser.singleOpt)
}
But I don't understand why this error happens because newConf is a var and normally the Conference.forGroup should be one too.
If you see something done wrong, please tell me.
Thanks for help.