https://kotlinlang.org logo
Title
s

snowe

02/18/2019, 6:35 PM
Can anyone explain to me how to modify this to work in kotlin? There is no
hasNext()
method
, so I cannot perform whether there is an end in the
while
.
public static void printEachForward(BreakIterator boundary, String source) {
     int start = boundary.first();
     for (int end = boundary.next();
          end != BreakIterator.DONE;
          start = end, end = boundary.next()) {
          System.out.println(source.substring(start,end));
     }
 }
✔️ 1
b

Bilagi

02/18/2019, 6:37 PM
fun printEachForward(boundary: BreakIterator, source: String) {
    var start = boundary.first()
    var end = boundary.next()
    while (end != BreakIterator.DONE) {
        println(source.substring(start, end))
        start = end
        end = boundary.next()
    }
}
s

snowe

02/18/2019, 6:38 PM
fantastic. Thanks. Having a bit of trouble this morning.