SWIFT: Public getter and Private setter:- Private(Set)
2 min readDec 14, 2019
Swift supports public get but private set on properties:
Let’s have a look with sample code so that we can understand the need to use private(set) keyword-
The above picture depicts, there is a Student class with property rollNumber, firstName, and lastName and we have declared them as private property, hence we can’t use them directly.
But recently I came across a new and awesome way to do this in a single line statement like
Thank you for reading
This is my second article on Medium, I hope it will be useful for you. Please let me know your thoughts and opinions :). If you enjoyed it, feel free to hit the clap button below 👏 to help others find it!