79483743

Date: 2025-03-04 12:51:13
Score: 2
Natty:
Report link

I think the only way is using inheritance (if it fits your needs. If not, please provide more details on how you want to use this protocol):

protocol Protocolable {
    var data: Int { get }
    
    func update()
}

class Dummy: BaseProtocolable {
    
    //any specific to Device class code
}

class Device: BaseProtocolable {
    
    //any specific to Device class code
}

class BaseProtocolable: Protocolable {
    private(set) var data: Int = 0
    
    func update() {
        updateData()
    }
    
    private func updateData() {
        data = 100
    }
}
Reasons:
  • RegEx Blacklisted phrase (2.5): please provide
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Kiryl Famin