This has occurred to me as well, but I suppose it only makes sense for input parameters, e.g. some Array
could not be a return type. The function implementer would know what Element
is but as a caller you wouldn't. Unless the idea is that the actual type is revealed to you implicitly:
func foo() -> some Array {
[1, 2, 3]
}
let x = foo() // x is now [Int]
EDIT:
Turns out this already works for some Collection
, so I guess it would make sense for some Array
as well.
func foo() -> some Collection {
[1, 2, 3]
}
func bar() {
let baz = foo() // some Collection in XCode
print(type(of: baz)) // prints Array<Int>
}