Yazzz
Yazzz

Reputation: 11

extract specific value from list

I have a list of records that returns in the following format

Record([email protected],Id=12313,optChoice=OUT, lastUpdateDate=2022-03-03T08:24:40.469898Z)

Record([email protected],Id=12313,optChoice=in, lastUpdateDate=2022-04-03T08:24:40.469898Z)

I want to return my opt choice and everything else can be ignored. Any tips on how to do that?

Upvotes: 0

Views: 29

Answers (1)

hazra
hazra

Reputation: 430

You can use the map function. For example: list.map { it.optChoice } (where list is the name of your list variable) which will return you a list of the optChoice values. See for more info: https://kotlinlang.org/docs/collection-transformations.html#map

Upvotes: 2

Related Questions