[ad_1]
I’ve one for loop the place I discovered index in repeating therefore I need to convert into foreach loop.
for (key, _) in particulars {
let product = product
particulars[key]?.title = product.first?.identify ?? ""
particulars[key]?.quantity = Double(product.first?.costs ?? 0.0)
}
I attempted this as under however nonetheless right here particulars[key]? is repeating
particulars.forEach { key, worth in
let product = product
particulars[key]?.title = cartProduct.first?.identify ?? ""
particulars[key]?.quantity = Double(product.first?.costs ?? 0.0)
}
Might I do know, the right way to convert this into foreach in Swift in order that I need not write [key] every-time.
[ad_2]
