[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using a global variable as default argument
From: |
Erik Leunissen |
Subject: |
Re: using a global variable as default argument |
Date: |
Sun, 23 Mar 2014 17:18:58 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
And now without the typo in the exercise below (sorry).
Erik Leunissen.
--
-- script file tst.m --
function rv = f(v=pi)
return v;
endfunction
--
> tst
> f()
ans = 3.1416
OK, that works. However, the following doesn't:
-- script file tst.m --
global myconst = 1.2345;
function rv = f(v=myconst)
return v;
endfunction
--
> tst
> f()
error: 'myconst' undefined near line 3 column 19