How to capture a for loop index after break?

Are you looking for the outer keyword?

function foo(p)
   local i
   for outer i = 1:100
       rand() > p && break
   end
   return i
end
15 Likes