如果我在Kotlin中有一个对象的集合,有没有快速的方法来获取这些对象的某个属性的集合?我看了一张collection operations for Kotlin人的名单,但没有什么特别适合我(但我可能忽略了一些东西)
In python it would be akin to:
[person.name for person in persons]
而且我更喜欢使用集合函数,而不是执行以下操作:
var nameMap = mutableListOf<String>()
persons.forEach{person -> nameMap.add(person.name)}
I'm pretty lacking in knowledge of filtering/lambda functions and anything other than list comprehension, so apologies if this is a simple question