I’m struggling with using the new map, flatMap, filter, reduce and zip functions. Consider the following: You have two arrays, A and B, containing different objects. For each object in A, you need to find the corresponding object in B (by their id property), and update some of the properties of the object from B. This could be done the old way, using two for cycles, like so:
private func update(statuses: [JobStatus], forJobs jobs: [JobBookPayload]) {
for jobStatus in statuses {
for job in jobs {
if jobStatus.jobId == job.jobId {
job.status = jobStatus.status!
job.option = jobStatus.option!
}
}
}
}
Can this be done using the new functions, to make the code more "Swifty" and improve readability?