How does Swift know the address of an element in an array of Any? I can’t find any explanation. For example:
var array: [Any] = [0, "1"] print(array) // print “1”
I’m wondering how does Swift implement accessing an array of heterogenous types. Usually, in other programming languages like C/C++, we can only declare an array of a specified type, therefore we can calculate the address of an element by:
start + index * Element.size . How to calculate the address of an element of array with a specified index if we don't have a fixed size of elements in the array?