Found an Answer:
Code
protocol Component { ... }
struct ComponentA: Component { ... }
struct ComponentB: Component { ... }
class Main<C: Component> {
var component: C
init(componentA: ComponentA, componentB: ComponentB) {
// I am trying to check, whether componentA equals the Generic Data Type and assign it to the component Property if true.
if let safeComponent = componentA as? C {
self.component = safeComponent
}
}
}
Topic:
Programming Languages
SubTopic:
Swift
Tags: