Pergunta de entrevista da empresa Yandex

You have a struct "Worker" with method that fetches one worker by id. Write method that will fetch multiple workers by array of ids.

Resposta da entrevista

Sigiloso

17 de jul. de 2019

struct Worker { func fetch(objectWithId id: String, completion: @escaping (Data) -> Void) { ... } } extension Worker { func fetch(objectsWithIds ids: [String], completion: @escaping ([Data]) -> Void) { var dataArr = [Data]() for i in ids.count-1 { fetch(objectWithId: ids[i]) { dataArr.append(Data) } } completion(dataArr) } }