I'm writing a simple app in vim + gradle: ``` clas...
# announcements
v
I'm writing a simple app in vim + gradle:
Copy code
class App {
  val listA = listOf(1, 8, 12, 17, 26, 31)
}

fun main(args: Array<String>) {
  val app = App()
  while (app.listA.hasNext()) {
    println(app.listA.next())
  }
}
But get this on
gradle run
Copy code
Unresolved reference: hasNext
Unresolved reference: next
Have I forgot something? Something in Gradle?
n
yes… the rest of the question 😄
v
Sorry, I'll explain
n
Ah, you need to get an iterator first
In saying that, I’d use forEach rather:
app.listA.forEach { println(it) }
v
Oops, my bad 🙂 Thanks
👍 1
One more question: how to reset iterator to the beginning?
n
I don’t think you can. Just get a new one from the list
v
Thanks, I have not found a way to do it myself, but I was not sure that I know everything 🙂
g
what is your use case? Because sample above perfectly replaced with forEach
v
It was test-case to reveal how iterators work
g
I see