Pergunta

If it is possible, how would I loop through a ListBuffer from within java. initialization of the ListBuffer (in scala)

var newModVersions: ListBuffer[NewModVersionEntry] = new ListBuffer[NewModVersionEntry]()

current smart for loop (in java)

for (VersionCheckHandler.NewModVersionEntry entry : XplosionCoreBL.newModVersions())
Foi útil?

Solução

You can use JavaConversions for that:

import scala.collection.JavaConversions;
//...
for (YourEntryClass entry : JavaConversions.asJavaIterable(yourListBuffer)) {

(I've switched to placeholder types and vars, since otherwise the example would be less readable)

See this answer to an "inverse" question for general info, and this question+answer for an explanation of the design approach taken in the Scala library.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top