I got list of objects. Each object has its values.
data class User(val name: String, val age: Int)
so I have a list of 15 Users each of them got name and age. How to make a separate list with only ages? Like convert listOfUsers to listOfAges?
CodePudding user response:
Transform the collection using map
:
val listOfAges = listOfUsers.map { it.age }