Programming Tips - How can I iterate through an ArrayList in Scala?

Date: 2013may22 Language: Scala Keywords: enumerate Q. How can I iterate through an ArrayList in Scala? A. If you have a legacy Java function that returns an ArrayList<> you can iterate this way:
import collection.JavaConversions._ for (str <- asScalaBuffer(OldCode.oldFunction())) { System.out.println(str); }
OldCode.oldFunction() is your legacy function. asScalaBuffer() converts your ArrayList. It can be an ArrayList of anything.