Scala: Best way to iterate over collection and populate Array -
scala noob here, have collection (seq) of xml nodes, , populate array based on each node:
val nodes = data.child \\"package" var packages = new array[package](nodes.length) var index = 0 for(val entry <- nodes) { packages(index) = new package(entry) index = index+1 }
although works, not "scala-ish" me, , i'm sure there's better way it..
any ideas?
(data.child \\ "package") map(new package(_)) toarray
Comments
Post a Comment