Questions tagged [setters]

A setter is a method used to control changes to a variable. It's most often used in object-oriented programming, in keeping with the principle of encapsulation.

1 question with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
1answer
109 views

restricting access to a public setter

My question is how I can achieve more encapsulation in TypeScript. I have a class Item, with a public setter isOwned, but I only want to call this method in specific situations: if the item is picked ...