Le lundi 25 janvier 2016 à 05:24 -0800, [email protected] a écrit : > Hi, > > I'd like this code: > > > function f1() > x = 1 > if !isdefined(:x) > x = 2 > end > println(x) > end > > function f2() > if !isdefined(:x) > x = 2 > end > println(x) > end > > f1() # prints 2, ideally should print 1 > f2() # prints 2, ideally should print 2 > > ideally to print: > > 1 > 2 > > The problem is that isdefined works at global scope only... I've > found a trick here: https://groups.google.com/forum/#!topic/julia-dev > /HgEPayeJnDM by Simon Kornblith, but I've been unable to adapt it to > my case... Is there a way to do what I want? Maybe you could tell us what's your goal instead? For example, you could always define x, but make it a Nullable so that it doesn't necessarily contain a value.
Regards
