Having array of employee object, called employees and now I want to create another array called filteremployees which is having only id and date of birth value. Using let filteremployees = employee.map({ $0.id}) I can get array which contains only id value but i want to have id as well dateOfBirth
class Employee {
var id: Int
var firstName: String
var lastName: String
var dateOfBirth: NSDate?
init(id: Int, firstName: String, lastName: String) {
self.id = id
self.firstName = firstName
self.lastName = lastName
}
}
Employeeis a good candidate for being astructhere. And the properties are good candidates for being declared withletinstead ofvar. Look a what Abizern has done with theFilteredEmployee struct.