Ex10 - Setting the completionDate

Azazel
Windoof-User
Windoof-User
Beiträge: 30
Registriert: 26. Apr 2017 19:10

Ex10 - Setting the completionDate

Beitrag von Azazel » 27. Jan 2018 17:41

Hi,

I am currently having trouble setting the completionDate of a SimpleTask. On initialization I override the Task traits value with None.

Code: Alles auswählen

override def completionDate: Option[Instant] = None
I would like the markDone-method to change the completionDate to Instant.now but get an error stating I can not reassign a val. Is there a way to change an Options value from None to Some after it was initialized?

Benutzeravatar
Stefan94
Erstie
Erstie
Beiträge: 15
Registriert: 15. Apr 2015 15:35

Re: Ex10 - Setting the completionDate

Beitrag von Stefan94 » 29. Jan 2018 21:54

Yes, don't define it as a val / method.
Define it as a var. I.e.

Code: Alles auswählen

var completionDate : Type = Value

Antworten

Zurück zu „Archiv“