Reputation: 529
I have the following code :
function test
s1=1;
s2=-1;
function inner_test
s2=1;
if s1==s2
display('success')
end
end
end
I thought it would display 'success', but it does not! Why is that? Does it have to do with variables scope?Is there a workaround?
Upvotes: 0
Views: 67
Reputation: 8211
Your inner function is never called. Try this, and success
is displayed:
function test
s1 = 1;
s2 = -1;
function inner_test
s2 = 1;
if s1 == s2
display('success')
end
end
inner_test()
end
Upvotes: 3