Java->Scala Remove Iterator<T>-Element from a JavaConversions-wrapped Iterable
- by ifischer
I have to translate the following code from Java to Scala:
for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();)
{
ExceptionQueuedEvent event = i.next();
try {
//do something
} finally {
i.remove();
}
}
I'm using the JavaConversions library to wrap the Iterable. But as i'm not using the original Iterator, i don't know how to remove the current element correctly from the collection the same way as i did in Java:
import scala.collection.JavaConversions._
(...)
for (val event <- events) {
try {
//do something
} finally {
//how can i remove the current event from events?
}
}
Can someone help me?
I guess it's easy, but i'm still kinda new to Scala and don't understand what's going on when Scala wraps something of Java.