Daily iOS
Swift

Opaque vs existential types

From the caller's side, what's the difference between func make() -> some Shape and func make() -> any Shape?

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

some is an opaque type: the compiler knows the one concrete type behind it. any is an existential that can hold any Shape, so the caller doesn't know what's inside.

Share a question