# How to capture a for loop index after break?

**URL:** https://discourse.julialang.org/t/how-to-capture-a-for-loop-index-after-break/46342
**Category:** General Usage
**Created:** [September 9, 2020, 6:56pm UTC](https://discourse.julialang.org/t/how-to-capture-a-for-loop-index-after-break/46342 "2020-09-09T18:56:10Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)
#### Post date: [September 9, 2020, 7:27pm UTC](https://discourse.julialang.org/t/how-to-capture-a-for-loop-index-after-break/46342/4 "2020-09-09T19:27:53Z")

</div>

Are you looking for the `outer` keyword?

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

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-capture-a-for-loop-index-after-break/46342)._
