# Tips on how to use let blocks to shadow local variables and avoid accidentally modifying the original variable

**URL:** <https://discourse.julialang.org/t/tips-on-how-to-use-let-blocks-to-shadow-local-variables-and-avoid-accidentally-modifying-the-original-variable/101467>\
**Category:** General Usage\
**Created:** [July 11, 2023, 3:35am UTC](https://discourse.julialang.org/t/tips-on-how-to-use-let-blocks-to-shadow-local-variables-and-avoid-accidentally-modifying-the-original-variable/101467 "2023-07-11T03:35:13Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Post date:** [July 11, 2023, 7:00am UTC](https://discourse.julialang.org/t/tips-on-how-to-use-let-blocks-to-shadow-local-variables-and-avoid-accidentally-modifying-the-original-variable/101467/5 "2023-07-11T07:00:49Z")

</div>

> [@HanD](#):
>
> ```julia
> gobal_value = let _ = 0, # dummy assignment to "carry" the comma and the line break
> x = <expression-to-compute-x>, # note the comma
> y = <expression-to-compute-y> # note the missing comma
> # intentional blank line to separate the body from the declarations
> <expression-using-x-and-y>
> end
> 
> ```

What is wrong with just using

```julia
gobal_value = let x, y
    x = <expression-to-compute-x>
    y = <expression-to-compute-y>
    <expression-using-x-and-y>
end

```

---

_[View the full topic](https://discourse.julialang.org/t/tips-on-how-to-use-let-blocks-to-shadow-local-variables-and-avoid-accidentally-modifying-the-original-variable/101467)._
