collections - Select property from each object in a list -
say have list<tuple>, first element in each string. there extension function in kotlin select first element each of these tuples?
i'm looking c# linq syntax select:
mytuples.select(t => t.item1)
in kotlin, tuple pair or triple. map on list , select out first element, this:
val mytuples : list<triple<string,string,string>> = listof( triple("a", "b", "c"), triple("d", "e", "f") ) val myfirstelements: list<string> = mytuples.map { it.first } // ["a", "d"] and of course, can leave off types, i've left them in make easier follow.
Comments
Post a Comment