Scala: Best way to iterate over collection and populate Array

scala noob here, i have a collection (Seq) of xml nodes, and i would like to populate an 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 it works, does not look much "scala-ish" to me, and i'm sure there's a better way to do it.. Any ideas?


(data.child \\ "package") map(new Package(_)) toArray

Need Your Help

Network Reachability with UIWebView

iphone xcode networking app-store

i just finished my first app which is a fullscreen view of my web app. it works fine and i was about to submit it but i noticed that apple requires network Reachability. I have tried many ways of d...

Deploying SQL Server Databases from Test to Live

sql-server sql-server-2005 deployment release-management

I wonder how you guys manage deployment of a database between 2 SQL Servers, specifically SQL Server 2005.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.