I'm looking to try and cast a type based on a variable. The example below fails saying "Use of undeclared type, 'myType'"
protocol Parent {}
protocol Child: Parent {}
struct Foo: Child {}
let foo: Parent = Foo()
let myType = Child.self
if let _ = foo as? myType {
print("success")
}
Is there any way to cast based on the variable myType?