elect
01/29/2020, 11:26 AMwhile (true) { }
might be simplified to while { }
Dominaezzz
01/29/2020, 11:31 AMelect
01/29/2020, 11:34 AMjimn
01/30/2020, 2:06 PMelect
01/30/2020, 2:06 PMLeon Linhart
01/30/2020, 4:26 PMwhile { }
feels wrong because "while" implies that the code is executed while some condition is true which is not the case for an infinite loop. (for { }
suffers from a similar problem.)elect
01/30/2020, 4:29 PMDominaezzz
01/30/2020, 5:09 PMloop { }
stantronic
01/31/2020, 10:32 AMinline fun loop(block: ()->Unit){
while(true) block.invoke()}
jimn
01/31/2020, 4:19 PMKy Leggiero
03/20/2020, 5:30 PMbreak
and continue
in a while (true)
block, you should instead be looking at other, better-fitting patterns. Perhaps the condition that causes you to hit break
should be in the parentheses instead of true
, or perhaps you should be using for
, filter
, any
, etc.