I use an internal library for init objects. This library accepts only var attributes, but I don't want to change var attributes after init. This task is done by declaring attributes as let, but I can`t do that.
As a solution a use private(set) and it works very well.
But, I want to know, is there any difference between var private(set) and let?
Thanks!
let
stops you from changing the value.
private(set) var
stops anything outside of the file from changing the value, while the class itself still has the power to modify it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With