mardi 21 avril 2015

Flattening nested java lists in Scala

I am working in Scala with java libraries. One of these libraries returns a list of lists. I want to flatten the list.

Example:

import scala.collection.JavaConverters._
var parentList : util.List[util.List[Int]] = null
parentList = new util.ArrayList[util.List[Int]]

parentList.asScala.flatten // error

I have used asScala converter but I'm still meeting an error.

Aucun commentaire:

Enregistrer un commentaire