Intermediate
Swift
Q78 / 100
What is Swift's existential container layout?
Correct! Well done.
Incorrect.
The correct answer is B) A 5-word heap allocation for any type conforming to a protocol: value buffer + type metadata + protocol witness tables
B
Correct Answer
A 5-word heap allocation for any type conforming to a protocol: value buffer + type metadata + protocol witness tables
Explanation
var drawable: any Drawable stores up to 3 words inline; larger values heap-allocate. Plus 1 word for type metadata and 1 for the witness table. This overhead justifies preferring generics.
Progress
78/100