# Let expression problem

**URL:** <https://discourse.julialang.org/t/let-expression-problem/43734>\
**Category:** General Usage\
**Created:** [July 27, 2020, 12:56am UTC](https://discourse.julialang.org/t/let-expression-problem/43734 "2020-07-27T00:56:56Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [July 27, 2020, 3:16pm UTC](https://discourse.julialang.org/t/let-expression-problem/43734/5 "2020-07-27T15:16:39Z")

</div>

I think the subtlety here is that:

```julia
let x = ...

```

behaves differently than

```julia
let
  x = ...

```

For example:

```julia
julia> let
         x = 1
         let x = 2
           x = 3
         end
         @show x
       end
x = 1
1

julia> let
         x = 1
         let 
           x = 2
           x = 3
         end
         @show x
       end
x = 3
3

```

The same issue is discussed in [Variable declarations within let blocks](https://discourse.julialang.org/t/variable-declarations-within-let-blocks/29882)

I actually don’t think the manual is very clear on this topic: [Scope of Variables · The Julia Language](https://docs.julialang.org/en/v1/manual/variables-and-scoping/#Let-Blocks-1)

In particular, it says

> An assignment modifies an existing value location, and `let` creates new locations. This difference is usually not important, and is only detectable in the case of variables that outlive their scope via closures.

I think something like the answer from [Variable declarations within let blocks](https://discourse.julialang.org/t/variable-declarations-within-let-blocks/29882) would be a good addition to that section of the manual.

---

_[View the full topic](https://discourse.julialang.org/t/let-expression-problem/43734)._
