Problem with pass-by-sharing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with pass-by-sharing

Thuener Silva

I understand the pass-by-sharing concept, but how can I use only the variable value on a function?

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 want this function to change when I change the value of a.


Grats,

Thuener Silva


Reply | Threaded
Open this post in threaded view
|

Problem with pass-by-sharing

Tony Kelman
Please only post this kind of question to julia-users, not julia-dev.

Ref https://groups.google.com/forum/m/#!topic/julia-users/2NHfctUWeOk