Title
Question
function foo(a)
a=a+1
b=return(a)
c=52
endfunction
foo(42);
assert_checkequal(43,b)
the above code is right out of the help file for return: so foo is returning the value of a as b. And the above does work. However, when I modify the next to last line as follows:
x=foo(42), I'm assigning b into x, at least that's what I thought. Instead I get
Wrong number of output arguments. as an error. This would have worked in C or C++, so what am I missing here? Also in the help file there is a mention to the use of the following syntax:
\r\n
the syntax <code class="scilabcode"><font face="Courier New"><span class="scilabfkeyword">function</span> \r\n <span class="scilabinputoutputargs">b</span><span class="scilaboperator">=</span><span class="scilabfunctionid">foo</span><span class="scilabopenclose">()</span></font></code> \r\n is recommended.\r\n Supposedly to eliminate the return.
So suppose I modified the previous code to:
function x=foo(a)
a=a+1
//b=return(a)
c=52
endfunction\r\n to get rid of the return
\r\n \r\n\r\nHow do I know what gets assigned to x unless there is a return(a). After all there is an a and a c in the function. And the code doesn't work anyway. The mention of this form of function declaration is minimal, to say the least, and to further exacerbate the matter the help utility does not show anything when I search for function. I did accidentally find some information on debugging, which saved me from making a post about where the debugger is.
Scilab Getting-Started 16-17 min 50-60 sec
Answers:
function foo(a)
a=a+1
b=return(a)
c=52
endfunction
foo(42);
assert_checkequal(43,b)
kindly reply <a href="http://www.sscguide.in/jht-result/" target="_blank" title="">here</a>
Login to add comment