Daily iOS
Swift

ContiguousArray vs Array

Say your resume claims "ContiguousArray is faster than Array." In a pre-interview the interviewer asks, "Then why don't developers use ContiguousArray much in practice?" How would you answer?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

When elements are structs or enums, Array already uses a contiguous buffer, so there's no difference; the gain is small against the API compatibility and ecosystem cost, so use it only when a benchmark shows a bottleneck.

Share a question