Protocol ambiguity


How to differentiate protocol ambiguity

protocol X{}
extension X{
    func render(){
        Swift.print("X")
    }
}
protocol Y{}
extension Y{
    func render(){
        Swift.print("Y")
    }
}
class A:X,Y{//👈 Conforms both X and Y
    func renderX() {
        (self as X).render()
    }
    func renderY() {
        (self as Y).render()
    }
}
let a = A()
a.renderX()//x
a.renderY()//y

Related Posts

Infinite Tree List

My notes on Infinite tree list

Protocol Inheritance

My notes on Protocol Inheritance

The Ultimate Xcode Workflow

Spend zero time managing dependencies

Faster Xcode With Spm

How you can speed up compile times in XCode with Swift Package Manager

Spm And Ci Travis

My notes on Swift PM + CI Travis

Spm And Nested Frameworks

My notes on Swift package manager + XCode + Nested frameworks

Xcode And Spm

Here is how you use Swift package manager in your XCode app projects

Carthage And Nested Frameworks

A few workflows concerning Carthage and nested framework

Two Finger Swipe

Notes on implementing two finger swipe for macOS

Switch

Notes about the Switch component