I have seen several questions regarding "expression implicitly coerced from an Optional
to Any
"(such as this and this), but I did not find one explaining the reason why Optional
is not "included" in Any
, since, according to the Apple's Swift Standard Library, Optional
is a generic enum
type.
Any
parameters are expected for the print
function, so providing Optional
would give the warning message. However, since Optional
is an enum type, shouldn't it be an Any
type as well? Why is Optional
, as an enum type, not part of the Any
type such that the compiler needs to convert Optional
to Any
?