'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?



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 hazra