0

SetVar or this.var

Should I use Setter method in constructor or just change it with this.var?

12th Feb 2019, 1:40 AM
Player Clash_of_Clans
Player Clash_of_Clans - avatar
2 Answers
+ 2
If you found that you needed to, and have implemented a sort of validation mechanism in the setter, then use setter, you can't apply validation when merely assigning member value directly to the `this.<member_name>` thus invalid value assignment is possible IMO.
12th Feb 2019, 7:43 AM
Ipang
+ 1
Hm... This makes sense. Thank you)
12th Feb 2019, 8:47 AM
Player Clash_of_Clans
Player Clash_of_Clans - avatar