I have a custom array like this and I want to delete the element where Student id is 4
var strNames = [Student(id: 1, name: "ghj"), Student(id: 4, name: "def"), Student(id: 9, name: "bkl")]
In classic way I do like this. Can anybody please help me mapping in Swift way?
var sArray2: [Student] = []
for item in strNames {
if item.id != 4 {
sArray2.append(Student(id: item.id, name: item.name))
}
}
strNames = sArray2