I am looking for a way to resolve the below compilation error in Scala. I am trying to update the value of a variable clinSig
, if the clinSig
is null while calling method1
.
import org.joda.time.Instant
import java.util.Calendar
class TestingClass {
method1(null)
private def method1 (clinSig : Instant) {
if (clinSig == null) {
val calendar = Calendar.getInstance()
calendar.set(2011, 0, 5, 0, 0, 0)
calendar.set(Calendar.MILLISECOND, 0)
clinSig = new Instant(calendar.getTime)
}
print(clinSig)
}
}
error: reassignment to val
[INFO] clinSigUpdtDtTm = new Instant(calendar.getTime)