here is my code
class Foo<T> {
}
class Main {
static func test() {
var foo: Foo<Any>
var bar = Foo<String>()
//Do all my stuff with foo necessitating String
foo = bar
}
}
When I try to assign foo = bar
I get an error Cannot assign a value of type Foo<String> to a value of type Foo<Any>
.
I don't understand why I got this error, since String conforms to Any.
If I do exactly the same thing but using Array, I don't have any error
static func test() {
var foo: Array<Any>
var bar = Array<String>()
//Do all my stuff with foo necessitating String
foo = bar
}
Does anyone know what's wrong with my code? Thanks