Consider the following code:

x = 0

y = 1

if y>0

f(x) = x

else

f(x) = 10000

end

y = (f(x))^2

println(y)

Running this code simply prints 0. No surprises here. Now, define the function myfun as follows:

function myfun(x, y)

if y>0

f(x) = x

else

f(x) = 10000

end

y = (f(x))^2

return y

end

Then, I expected that myfun(0,1) would return the same value as the above code. But actually it does not but it returns 100000000.

What am I not understanding here? Please help…