And since this is a scoping problem, `let` is your friend
```
julia> a = 20
julia> let a = a
global f
f(x) = x*a
end
f (generic function with 1 method)
julia> f(20)
400
julia> a = 40
40
julia> f(20)
400
```
On Fri, Oct 9, 2015 at 10:36 AM, Tomas Lycken <[email protected]>
wrote:
> Then don't use the same variable ;)
>
> ```
> julia> a = 10;
>
> julia> _a = a;
>
> julia> f(x) = _a * x;
>
> julia> f(2)
> 20
>
> julia> a = 20;
>
> julia> f(2)
> 20
> ```
>
> This has nothing to do with pass-by-sharing, but rather with scoping - the
> manual talks quite a lot about this (but don't hesitate to suggest
> improvements if something is unclear to you!)
> http://docs.julialang.org/en/release-0.4/manual/variables-and-scoping/
>
> // T
>
>
> On Friday, October 9, 2015 at 4:26:38 PM UTC+2, Thuener Silva wrote:
>>
>> I understand the pass-by-sharing concept, but if I want to use only the
>> value of a variable?
>> Simple example to illustrate what I'm trying to say:
>>
>> julia> a = 10
>> 10
>>
>> julia> f(x) = a*x
>> f (generic function with 1 method)
>>
>> julia> f(2)
>> 20
>>
>> julia> a = 20
>> 20
>>
>> julia> f(2)
>> 40
>>
>> I don't wan to to change the function when I change the value of a.
>>
>> Grats,
>> Thuener Silva
>>
>