'Val cannot be reassigned error in constructor
I want to reassign a new value in the constructor, but I can't.
class InstantDate {
private var date: LocalDateTime? = null
constructor(date: String) {
if (date.contains(" "))
{
date = date.replace(" ", "T")
this.date = LocalDateTime.parse(date)
}
}
}
I get the error "val cannot be reassigned."
How can I solve this without creating a new value? Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
