Last active
May 15, 2022 11:10
-
-
Save enginebai/13efbea0cf72b9b96b93aa412bb8b8d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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