scala - Extract second tuple element in list of tuples -


i have map each value list of tuples such as:

list(('a',1), ('b', 4), ('c', 3)....) 

what scala-thonic way change each value still list second element of each tuple

list(1,4,3) 

i have tried

mymap.mapvalues(x => x._2) 

and

error: value _2 not member of list[(char, integer)] 

any tips?

try this:

    mymap.mapvalues(_.map(_._2)) 

the value passed mapvalues list[(char,integer)], have further map second element of tuple.


Comments