kevinmost
03/07/2018, 6:25 PMwhile (true)
with a break
over crazy assignments in the while
condition:
var len: Int = 0
while (true) {
len = def.deflate(buf, 0, buf.size)
if (len <= 0) break
...
}
araqnid
03/07/2018, 6:27 PMcedric
03/07/2018, 6:29 PMkevinmost
03/07/2018, 6:36 PMkevinmost
03/07/2018, 6:36 PMelizarov
03/07/2018, 6:48 PMevanchooly
03/07/2018, 6:51 PMcedric
03/07/2018, 6:56 PMcedric
03/07/2018, 6:57 PMcedric
03/07/2018, 6:58 PMwhile
probably beats all the other alternatives and Iām guessing while(true)
+ break
might beat while(keepGoing)
, but thatās just a gut feelingkevinmost
03/07/2018, 7:30 PMwhile ((len = obj.someLongMethodThatObscuresTheIntentOfThisCondition()) > 0) { ... }
conditional statementkevinmost
03/07/2018, 7:31 PMloop { ... }
for this case, which is basically an alias for while (true) { ... }
evanchooly
03/07/2018, 7:32 PMforEach(int) { }
to hide that all awaykarelpeeters
03/07/2018, 7:33 PMrepeat(int) { ... }
exists in the stdlib aleady.kevinmost
03/07/2018, 7:33 PMkevinmost
03/07/2018, 7:33 PMevanchooly
03/07/2018, 7:33 PMcedric
03/07/2018, 7:35 PMrepeat(Long.MAX_VALUE) { // should be big enough
karelpeeters
03/07/2018, 7:35 PMkevinmost
03/07/2018, 7:37 PMinline fun loop(block: () -> Unit) {
while(true) { block() }
}
škevinmost
03/07/2018, 7:37 PMNothing
karelpeeters
03/07/2018, 7:37 PMreturn@loop
, right?kevinmost
03/07/2018, 7:38 PMwhile (true)
would still continue though, wouldn't it? š¤evanchooly
03/07/2018, 7:39 PMdeviant
03/07/2018, 9:03 PMrepeat(Long.MAX_VALUE) {
repeat(Long.MAX_VALUE) { // if 1 repeat isn't enough
}
}
araqnid
03/07/2018, 9:49 PM