Protocol conformance adoption in Swift
Forums:
protocol Cleanable {
func Clear()
}
class IntList {
var items: [Int] = []
//some implementation...
func Clear() {
items.removeAll()
}
}
extension IntList: Cleanable {}
let list = IntList()
let isCleanable = list is Cleanable
//isCleanable is true
- Log in to post comments