#Different ways to continue from parent loop

1 messages · Page 1 of 1 (latest)

thorn steppe
#

I'm looking for a way to exit out of a parent loop without labeled loops. It's just since I think my code looks a bit odd when there's some loops that are labled and others that aren't.

  mylabel: for(arr) |c| {
             foo(c); 
  }

  for(arr2) |c| {
    bar(c)
  }

I don't know if it's just me or if there's other options, but I was just curious.

flint glen
#

first of all, you wouldn't indent the loop body because of a label

#

second of all, you can't break an outer loop without a label but you can continue one by labelling the body of the outer loop and breaking that (effectively contiuing the outer loop)