The type erased Any has a fixed layout of size 32 on 64b and 16 on 32b which contains enough information to recover the original type and value. If I were to write this out in C/C++:

struct Any {
  size_t data[3];
  const void *type;
};

So in this case, an array of Any is simply an array of that structure as it's single element type. Swift's print does some reflection when it encounters this Any type to print the actual value within it. Also, keep in mind that array's elements may not always be contiguous, so if you want to access its contiguous memory I would suggest using: withContiguousStorageIfAvailable.

7 Likes