Florian
07/08/2019, 10:00 AM1.plus(2)
. Is there also a form like this for in
when it uses iterator
(not contains
)?diesieben07
07/08/2019, 10:02 AMiterator
😛diesieben07
07/08/2019, 10:02 AMIterator
which you can then traverse using hasNext
and next
callskralli
07/08/2019, 10:10 AMin
stands for iterator()
. So what exactly are you trying to achieve?kralli
07/08/2019, 10:12 AMiterator.forEach { }
might be a solution.Florian
07/08/2019, 10:25 AMFlorian
07/08/2019, 10:25 AMFlorian
07/08/2019, 10:25 AMdiesieben07
07/08/2019, 10:26 AMFlorian
07/08/2019, 10:27 AM(i in 1..10)
Florian
07/08/2019, 10:27 AMFlorian
07/08/2019, 10:28 AMFlorian
07/08/2019, 10:28 AMFlorian
07/08/2019, 10:28 AMdiesieben07
07/08/2019, 10:28 AMval it = (1..10).iterator()
Florian
07/08/2019, 10:29 AMdiesieben07
07/08/2019, 10:29 AMIterator
which you can go through using for...in
or hasNext()
and next()
diesieben07
07/08/2019, 10:30 AMFlorian
07/08/2019, 10:30 AMDico
07/08/2019, 5:59 PMfor (i in iterator)
Because the stdlib has
fun Iterator<T>.iterator() = this
Florian
07/08/2019, 6:11 PMin
brings me to the iterator functionFlorian
07/08/2019, 6:11 PMRyan Mentley
07/08/2019, 9:47 PMcontains
Ryan Mentley
07/08/2019, 9:47 PMRyan Mentley
07/08/2019, 9:48 PMsomeObject.contains(someOtherObject)
diesieben07
07/09/2019, 7:47 AMFlorian
07/09/2019, 11:01 AMFlorian
07/09/2019, 11:01 AMdiesieben07
07/09/2019, 11:10 AMfor...in
construct compiles to several method calls: One call to iterator
and then a while loop that repeatedly calls next
until hasNext
returns false.diesieben07
07/09/2019, 11:10 AMin
cannot be replaced by just a single method call.Florian
07/09/2019, 12:28 PM