How to get a List of Maps from a List of Objects in Scala -
i need scala. have troubles in understanding how deal collections. have traversing list this
list( myobject(id, name, status), ..., myobject(id, name, status) ) and getting list one
list( map("key", id1), map("key", id2), ..., map("key", idn) ) notice 'key' element of maps have same
thanks
you can use map function transform list of myobject list of map by:
val list = list( myobject(id, name, status), ..., myobject(id, name, status) ) val result = list map {o => map("key" -> o.id)} scala school twitter reading beginners, , if want know architecture of scala collections framework in detail, please refer scala doc
Comments
Post a Comment