If a field is declared as a var then Scala generates
field.
methods for that
Answers
Answered by
0
Answer:
join girl for fun I'd -657 729 4778
password-kaus
Answered by
0
Answer:
If a field is declared as var, Scala creates both getter and setter methods for that field. If the field is a val, Scala only spawns a getter method for it.
Explanation:
Here's the abridged version here:
- If a field is declared as var, Scala generates both getter and setter methods for that field.
- If the field is a val, Scala only generates a getter method for it.
- If a field does not have a var or val modifier, Scala becomes conservative, and does not generate a getter or setter method for the field.
- Additionally, the var and val fields can be modified with the private keyword, which prevents getters and setters from being generated.
Similar questions