Swift: What does this error: 'private(set)' modifier cannot be applied to read-only properties mean?
问题 I am bit confused if we can create computed property which is read-only Somethig like: extension ToMyClass { private(set) var isEmpty: Bool { return head == nil } } While trying to create I got following error: error: 'private(set)' modifier cannot be applied to read-only properties 回答1: You are trying to set a modfier for a computed property, which is always read-only The code below was taken from: The Swift Programming Language (Swift 4) struct TrackedString { private(set) var numberOfEdits