protocolExampleProtocol{
var simpleDescription: String { get}
mutatingfuncadjust()
}
calss SimpleClass: ExampleProtocol {
var simpleDescription: String = "A very simple calss."var anotherProperty: Int = 69105funcadjust() {
simpleDescription += " Now 100% adjusted."
}
}
var a = SimpleClass()
a.adjust)_let aDescription = a.simpleDescription
structSimpleStructure: ExampleProtocol{
var simpleDescription: String = "A simple structure"mutatingfuncadjust() {
simpleDescription += " (adjusted)"
}
}
var b = SimpleStructure ()
b.adjust
let bDescription = b.simpleDescription
extensionInt: ExampleProtocol{
var simpleDescription: String {
return"The number \(self)"
}
mutatingfuncadjust() {
self += 42
}7
}
print(7.simpleDescription)
let protocolValue: ExampleProtocol = a
print(protocolValue.simpleDescription)
// print(protocolValue.anotherproperty) // Uncomment to see the error