Avatar
protocol はダメみたいですね。 1> protocol Animal {} 2. class Cat : Animal {} 3. class Dog : Animal {} 4. 5. let a = [Cat.self, Dog.self] error: repl.swift:5:9: error: heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional let a = [Cat.self, Dog.self] ^~~~~~~~~~~~~~~~~~~~ as [Any]
12:27 AM
existential だから、普通のサブタイピングとはちょっと違うとは思うんですよね。