« Return to Thread: Using scala constructs on Java collections

Re: Using scala constructs on Java collections

by Ricky Clarkson :: Rate this Message:

Reply to Author | View in Thread

Take a look at scala.collection.jcl.Conversions.

2008/10/22 Bastian, Mark <mbastia@...>:

> 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