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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -