Setting can be modified, so can get element too? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Setting can be modified, so can get element too?

So if the for example setting can be modified can an get accessor of property be also optimized (modified) like if something return something else return somethin else or are there any limits with any of them?

11th Aug 2021, 3:00 PM
Saba Salukvadze
Saba Salukvadze - avatar
1 Answer
+ 1
Yes. That is pretty much the whole point of public properties with getters and setters. The only limitation is that you are not exactly sending parameters when you call getters or setters. The concepts have to do with encapsulation. Creating a class with good encapsulation will inform you better on how getters and setters should be used.
11th Aug 2021, 6:16 PM
Kail Galestorm
Kail Galestorm - avatar