Suggested approach: Type erasure allows us to throw away some type information, for example to say that an array of strings is actually just AnySequence
– it’s a sequence containing strings, but we don’t know exactly what kind of sequence.
This is particularly useful when types are long and complex, which is often the case with Combine. So, rather than having a return type that is 500 characters long, we can just say AnyPublisher<SomeType, Never>
– it’s a publisher that will provide SomeType
and never throw an error, but we don’t care exactly what publisher it is.
Estimated difficulty: Advanced
See the full list of iOS interview questions
Link copied to your pasteboard.