Post

Replies

Boosts

Views

Activity

Reply to How to check if Data Type equals Generic Data Type and assign to Property if True?
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 } } }
Aug ’22