Consider an object, Notification, with the following properties:
id: String
body: String
repeats: Bool
and consider an array of Notifications, notifications:
let notifications = [Notification(id: "1", body: "body1", repeats: false),
Notification(id: "2", body: "body2", repeats: false),
Notification(id: "3", body: "body3", repeats: true)]
How can I use the higher-order filter() function to retrieve an array of Strings corresponding to each id?
In other words, I would like to write a filter() closure to which I pass my notifications and the resulting output is:
["1", "2", "3"]
Therefore, my filter comparison operator should be based on the property name. Is this achievable?