Skip to content

Instantly share code, notes, and snippets.

@enginebai
Last active May 15, 2022 11:10
Show Gist options
  • Save enginebai/13efbea0cf72b9b96b93aa412bb8b8d6 to your computer and use it in GitHub Desktop.
Save enginebai/13efbea0cf72b9b96b93aa412bb8b8d6 to your computer and use it in GitHub Desktop.
List<User> userList = ...
List<Int> leaderAgesList = listOf()
for (User u : userList) {
if (u.title.contain('lead')) {
leaderAgesList.add(u.age)
}
}
Int sum = 0
for (Int age : leaderAgesList) {
sum += age
}
println(sum.toDouble / leaderAgesList.size())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment