# Define a function in global scope inside another function

**URL:** https://discourse.julialang.org/t/define-a-function-in-global-scope-inside-another-function/102597
**Category:** General Usage
**Tags:** scope, function
**Created:** [August 8, 2023, 11:11am UTC](https://discourse.julialang.org/t/define-a-function-in-global-scope-inside-another-function/102597 "2023-08-08T11:11:08Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Qfl3x](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qfl3x/32/16227_2.png) [@Qfl3x](https://discourse.julialang.org/u/Qfl3x)
#### Post date: [August 8, 2023, 12:10pm UTC](https://discourse.julialang.org/t/define-a-function-in-global-scope-inside-another-function/102597/4 "2023-08-08T12:10:15Z")

</div>

My problem is this: [Initialize some functions at every remake in PDEProblem](https://discourse.julialang.org/t/initialize-some-functions-at-every-remake-in-pdeproblem/102078)

I’ve thought a possible solution would be to redefine

```julia
Temperature(t,x)

```

by defining a function:

```julia
function pde_solution(Tvec)
    interp = LinearInterpolation(Tvec, [1.,2.,3.,4.,5.])
    global Temperature(t, x) = interp(x)
    solve(prob, TRBDF2())
end

```

---

_[View the full topic](https://discourse.julialang.org/t/define-a-function-in-global-scope-inside-another-function/102597)._
