Replies: 3 comments 2 replies
-
Lots of nice ideas here! First, iterating n times. CoffeeScript has Second, executing code when a loop doesn't for item of iterable
break if match item
then/else
console.log 'Found!'
else/then
console.log 'Not found :-(' Somewhat crazy idea: if we replaced Related, |
Beta Was this translation helpful? Give feedback.
-
According to #362, the original example would be written like this: loop 1000
break if sum > 999
sum += it.value
it = it.next
unless break?
throw new Error 'limit hit" I do find the meaning clearer (no |
Beta Was this translation helpful? Give feedback.
-
I was looking at implementing |
Beta Was this translation helpful? Give feedback.
-
Sometimes it is nice to have a
while true
that throws after a number of steps is hit. Maybe there is a good shorthand for something like that.Ideally this same mechanism could be used after any loop completes. I guess it is semantically equivalent to Python's
else
and maybe we should go with that but theelse
naming is not immediately intuitive.Beta Was this translation helpful? Give feedback.
All reactions