I'm looking to optimize a loop without using a boolean conditional to check whether to perform some action if the loop terminates normally without breaking. In python I'd write this:
for x in lst:
if cond(x):
do_stuff_with(x)
break
else:
do_other_stuff()
In Coffeescript the best I can think of is to do something like this:
found = false
for x in lst
if cond x
found = true
do_stuff_with x
break
if not found
do_other_stuff()
Is there a Coffeescript idiom for this situation?