# Some clarification on \`@inbounds\`

**URL:** https://discourse.julialang.org/t/some-clarification-on-inbounds/69076
**Category:** General Usage
**Tags:** question
**Created:** [October 1, 2021, 9:38pm UTC](https://discourse.julialang.org/t/some-clarification-on-inbounds/69076 "2021-10-01T21:38:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![markmbaum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/markmbaum/32/32745_2.png) [@markmbaum](https://discourse.julialang.org/u/markmbaum)
#### Post date: [October 1, 2021, 9:38pm UTC](https://discourse.julialang.org/t/some-clarification-on-inbounds/69076/1 "2021-10-01T21:38:18Z")

</div>

I know that `@inbounds` can be applied before a statement like

```julia
x[i] = y

```

and it will elide the bounds check for the `setindex!` call on `x`. I’m a little confused about where else `@inbounds` can be applied, though. If I write

```julia
@inbounds for i = 1:n
    x[i] = i^2
    y[i] = exp(x[i])
    z[i] = 1/y[i]
end

```

does this elide all of the bounds checks in the loop?

---

<div class="post-metadata">

### Author: ![Luapulu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luapulu/32/17669_2.png) [@Luapulu](https://discourse.julialang.org/u/Luapulu)
#### Post date: [October 1, 2021, 9:43pm UTC](https://discourse.julialang.org/t/some-clarification-on-inbounds/69076/2 "2021-10-01T21:43:48Z")

</div>

Yes, all bounds checks in the loop block will be elided.

Also, I think you mean setindex! 🙂

---

<div class="post-metadata">

### Author: ![markmbaum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/markmbaum/32/32745_2.png) [@markmbaum](https://discourse.julialang.org/u/markmbaum)
#### Post date: [October 1, 2021, 9:51pm UTC](https://discourse.julialang.org/t/some-clarification-on-inbounds/69076/3 "2021-10-01T21:51:32Z")

</div>

does this also apply to nested loops?
