# Retrieve a value within a do block

**URL:** <https://discourse.julialang.org/t/retrieve-a-value-within-a-do-block/131121>\
**Category:** General Usage\
**Tags:** question, jump\
**Created:** [July 28, 2025, 1:54am UTC](https://discourse.julialang.org/t/retrieve-a-value-within-a-do-block/131121 "2025-07-28T01:54:27Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [July 29, 2025, 12:03am UTC](https://discourse.julialang.org/t/retrieve-a-value-within-a-do-block/131121/7 "2025-07-29T00:03:32Z")

</div>

> [@odow](#):
>
> ```julia-auto
> julia> cut
> 0
> 
> julia> cut = run_do_block() do
> cut = 1
> return cut
> end
> 1
> 
> julia> cut
> 1
> 
> ```

I’m afraid this method is unusable, and it is somewhat misleading for a new user. The reason is that in my context, the counterpart of `run_do_block` is `Thread.lock`. You have no idea what the concrete implementation of `Thread.lock` is—for example, it can `return nothing`—e.g.

```julia
julia> function run_do_block(f) # the concrete code implementation is entailed for proper inference
           f()
           return nothing
       end;

julia> cut = run_do_block() do # Here cut = the UPPER "return", not THIS "return"
           cut = 1
           return cut
       end;

julia> isnothing(cut) # it depends on the concrete code implementation of `run_do_block`
true

```

A related [post](https://discourse.julialang.org/t/will-my-variable-be-modified-in-a-do-block-very-subtle-to-anticipate/131124/12).

---

_[View the full topic](https://discourse.julialang.org/t/retrieve-a-value-within-a-do-block/131121)._
