How does “public private(set)” access modifiers work?

This just means that the getter for numberOfEdits is public, but the setter is private. There’s nothing more to it.

The reason in this case is so that you can read numberOfEdits publicly, but you can only set it via changing value. If it were fully public, then anyone could set it, but if it were only settable, then the didSet in value couldn’t modify it. private(set) is a compromise between those two.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)