Avatar
swiftbot BOT 1/28/2020 8:13 AM
Author icon
omochimetaru
protocol Animal {} class Cat: Animal {} class Dog: Animal {} let a = [Cat(), Dog()] print(type(of: a))
Version:
swift-5.1.3-RELEASE
Output:
Error:
/usercode/main.swift:5:9: error: heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional let a = [Cat(), Dog()] ^~~~~~~~~~~~~~ as [Any]