Merge arrays with condition
<p>I would like to merge two arrays with specific condition and update objects that they are containing.</p>

<p>First my struct that is in arrays:</p>

<pre><code>struct Item {
    var id:Int
    var name:String
    var value:Int
}
</code></pre>

<p>Second elements for the two arrays:</p>

<pre><code>let fisrt = Item(id: 1, name: "Oleg", value: 3)
let second = Item(id: 2, name: "Olexander", value:5)

let fisrtInSecond = Item(id: 1, name: "Bogdan", value: 6)
let secondInSecond = Item(id: 2, name: "Max", value: 9)
</code></pre>

<p>Arrays:</p>

<pre><code> var fisrtArray = [fisrt, second]
 let secondArray = [fisrtInSecond, secondInSecond]
</code></pre>

<p>I woudl like to use <code>zip</code> and <code>map</code> functions of the collection to achive result. Result is that <code>fisrtArray</code>  elements <code>names</code> are updated by <code>id</code>.</p>

<p>Example: <code>fisrtArray = [Item(id: 1, name: "Bogdan", value:3), Item(id: 2, name: "Max", value:5)]</code></p>

<p>I know how to do this via simple loops. But i am looking for more advanced usage of the functional programing is Swift.</p>

<p>My experiment:</p>

<pre><code>fisrtArray = zip(fisrtArray, secondArray).map()
</code></pre>

<p>The main problem i do not know how to write condition in the <code>map</code> function. Condition should be:</p>

<pre><code>if ($0.id == $1.id) {
   $0.name = $1.name
}
</code></pre>

<p><strong>From the comment discussing it is possible to highlight that <code>zip</code> is not suitable in my case because we should iterate over all array to find if we have similar id's that are not in the same order.</strong></p>