Given an array containing instances of several SubClasses (all having the same SuperClass), I want to check if all the elements of another array of required subClass Types are represented by the instances.
I came up with what I think is a valid solution, but I'm plagued by the error: Use of undeclared type 'requiredType' in the closure for requiredTypes.allSatisfy { ... }
class MyClass { }
class SubClass1: MyClass { }
class SubSubClass1: SubClass1 { }
class SubClass2: MyClass { }
class SubClass3: MyClass { }
let requiredTypes = [SubClass1.self, SubClass2.self]
let instances = [SubSubClass1(), SubClass2()]
let meetsRequirements = requiredTypes.allSatisfy { (requiredType) -> Bool in
return instances.map({$0 is requiredType}).contains(true)
}