What's the easiest/right way to update an item in an array? I want the caller to have the updated array as well. So:
static func updateItem(updatedItem: Item, inout items: [Item]) -> Bool {
var item = items.filter{ $0.id == updatedItem.id }.first
if item != nil {
item = updatedItem
return true
}
return false
}
I want the caller to have the updated items (with the updated item). I think the problem with the above code is that it only updates the local variable item. What's the best way to actually update the relevant item inside the items array?