Skip to content

Instantly share code, notes, and snippets.

@saru2020
Created May 20, 2019 07:58
Show Gist options
  • Save saru2020/1946b0ae136ab43f70147081077ca4b0 to your computer and use it in GitHub Desktop.
Save saru2020/1946b0ae136ab43f70147081077ca4b0 to your computer and use it in GitHub Desktop.
let contactsDurationArr = contacts.map({ return $0.duration })//We use the map function to derive an array that contains only the duration property of all the objects
var sum = 0
for duration in contactsDurationArr {
sum = sum + duration
}
print(sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment