https://kotlinlang.org logo
#getting-started
Title
# getting-started
i

Ink

05/06/2022, 8:45 PM
Copy code
data class Foo(val price: Int?)
val items = List<Foo>(Foo(133), Foo(324), Foo(3))
How I can get
List<Int?>
with all prices? Is it only solution? https://medium.com/@hayi/kotlin-get-list-of-some-property-values-of-object-from-list-of-object-8da9419c2e77
d

Dariusz Kuc

05/06/2022, 8:50 PM
👍 3
c

Chris Lee

05/06/2022, 8:50 PM
Copy code
val prices = items.map { it.price }
2
p

phldavies

05/06/2022, 8:50 PM
items.map { it.price }
👍 2
i

Ink

05/06/2022, 9:06 PM
Thank you all!
2 Views