KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Suppose I have the following abstract class: abstract class A (var is_happy : Boolean) { def toggle_happiness(); } And now I want to define a concrete class which implements the toggle_happiness() method: class B (is_happy : Boolean) extends A (is_happy) { def toggle_happiness() = { is_happy = !is_happy } } Scala's compiler gives me: error: reassignment to val is_happy = !is_happy ^ What's going on here? I thought that is_happy referred to a var in my class that is set by my constructor. Do I have a conflict with the name is_happy ? Thanks, Dan
Tags (comma-separated)
Save Edits
Cancel