What happens if I omit this in the setter method? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What happens if I omit this in the setter method?

Are the color set for *all* the objects I create if I omit 'this'?

6th Jul 2017, 4:19 PM
.
. - avatar
1 Answer
+ 2
There is no difference for the objects you create, but for clarity and readability is better to use the 'this' keyword. You can omit it, if the local variables and arguments, which you want to assign to the instances, are with different names from them.
6th Jul 2017, 5:25 PM
Boris Batinkov
Boris Batinkov - avatar