« Return to Thread: Using scala constructs on Java collections

Using scala constructs on Java collections

by Bastian, Mark :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.
Is there a way to easily invoke foreach on a Java collection in a scala class?
 
Right now, all I can figure out is the old:
 
val iter = collection.iterator
while(iter.hasNext)
{
  val foo = iter.next
  foo.doIt
}
 
I'd much rather just do collection.foreach(x => x.doIt) or even be able to use the Java 5 enhanced for loop.
 
Thanks,
Mark
 

 « Return to Thread: Using scala constructs on Java collections