`while (true) { }` might be simplified to `while {...
# language-proposals
e
while (true) { }
might be simplified to
while { }
1
🤔 1
d
There's a YouTrack for this one actually. I'll find a link.
👌 1
e
thanks!
j
what about repeat{} ?
e
it sounds weird
l
while { }
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.)
1
e
logically, you should have a point. However given I'm used to read that in C, it feels natural
😓 1
d
loop { }
s
Copy code
inline fun loop(block: ()->Unit){ 
   while(true) block.invoke()}
1
(except that wont work with break and continue)
j
this thread is a mirror of the youtrack issue. it seems like the path of minimum resistance is probably something{...} however '...' as an operator is an infinite range semantic. does ... simply alias to Any?..POSITIVE_INFINITY ? will thaat be a follow-up stdlib request to try to reduce gap from maths to source code?
k
@stantronic If you find yourself using
break
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.