Why can I have an [AnyObject]
array and put a bunch of different sized types in it ...
var a = [AnyObject]()
a.append(Int(1))
a.append(Float64(3.14))
a.append(Bool(true))
... except for Int32
and Int64
....
a.append(Int32(1)) // err: type 'Int32' does not conform to protocol 'AnyObject'
a.append(Int64(1)) // err: type 'Int64' does not conform to protocol 'AnyObject'
The documentation for AnyObject
says:
“AnyObject can represent an instance of any class type”
But when I command-click on Int
, Int32
or Int64
to see the standard library definition of these types, I see that they are all struct
values.
What is the underlying issue here? Why is this designed like this?