编辑代码

protocol ExampleProtocol {
    var simpleDescription: String { get}
    mutating func adjust()
}



calss SimpleClass: ExampleProtocol {
    var simpleDescription: String = "A very simple calss."
    var anotherProperty: Int = 69105
    func adjust() {
        simpleDescription += " Now 100% adjusted."
    }
}
var a = SimpleClass()
a.adjust)_
let aDescription = a.simpleDescription

struct SimpleStructure: ExampleProtocol {
    var simpleDescription: String = "A simple structure"
    mutating func adjust() {
        simpleDescription += " (adjusted)"
    }
}
var b = SimpleStructure ()
b.adjust
let bDescription = b.simpleDescription




extension Int: ExampleProtocol {
    var simpleDescription: String {
        return "The number \(self)"
    }
    mutating func adjust() {
        self += 42
    }7
}
print(7.simpleDescription)



let protocolValue: ExampleProtocol = a
print(protocolValue.simpleDescription)
// print(protocolValue.anotherproperty)  // Uncomment to see the error