# Let statement cannot use return

**URL:** <https://discourse.julialang.org/t/let-statement-cannot-use-return/92948>\
**Category:** General Usage\
**Created:** [January 14, 2023, 2:34am UTC](https://discourse.julialang.org/t/let-statement-cannot-use-return/92948 "2023-01-14T02:34:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [January 14, 2023, 2:34am UTC](https://discourse.julialang.org/t/let-statement-cannot-use-return/92948/1 "2023-01-14T02:34:29Z")

</div>

I am trying to understand the let statement. Particularly how to get variables from within the let scope.

```julia
julia> j = 2
2

julia> c,d = let a = j
           x = 5a
           y = 7a
           return x, y
           end
(10, 14)

julia> c
ERROR: UndefVarError: c not defined

```

If I simplify this a bit I get

```julia
julia> c = let a = j
           x = 5a
           return x
           end
10

julia> c
ERROR: UndefVarError: c not defined

```

Okay I think I figured it out, the return should not be there!

```julia
julia> c,d = let a = j
           x = 5a
           y = 7a
           x, y
           end
(10, 14)

julia> c
10

julia> d
14

```

I will post this anyway in case it helps someone else

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 14, 2023, 2:36am UTC](https://discourse.julialang.org/t/let-statement-cannot-use-return/92948/2 "2023-01-14T02:36:24Z")

</div>

Let isn’t a function body so returning jumps you out of the entire statement before the outermost assignment is evaluated. This could be an error but that makes stepping through code from a function body annoying.
