Mark
01/30/2020, 10:39 AMfun myCheck(): Boolean
which I want to repeatedly call until it returns false. If I use while (myCheck()) {}
then I get a warning saying “control flow with empty body”. So I guess while
is supposed to be used with a non-empty body. Does this mean there is a more appropriate way?Francisco Javier Ruiz Rodriguez
01/30/2020, 10:57 AMwhile
Mark
01/30/2020, 10:58 AMFrancisco Javier Ruiz Rodriguez
01/30/2020, 11:00 AMdo {
val bool = myCheck()
}while(bool)
elizarov
01/30/2020, 11:04 AMMark
01/30/2020, 11:25 AMvar index = start
while (myCheck(index++)) { /* nothing to do */ }
Very much a style question, but I just wonder if there is a neater way - probably a for loop so that index
is encapsulated, but then the code is maybe too verbose.arve
01/30/2020, 11:29 AMvar index = start
while (myCheck(index++)) { continue; }
Mark
01/30/2020, 11:34 AMfor (int index = start; myCheck(index); index++) { /*do nothing */ }
kyleg
01/30/2020, 3:52 PMgenerateSequence(start){ it+1 }.takeWhile(::myCheck).count()
if you want to be kooky. :)James Richardson
01/31/2020, 8:03 AM