can a new function be defined in the middle of livescript?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Can one define a function in the middle of LiveScript or does it have to be at the end of the script?
0 Commenti
Risposta accettata
Fangjun Jiang
il 26 Mag 2020
Modificato: Fangjun Jiang
il 26 Mag 2020
No.
%%
a=1;
function out=timestwo(in)
out=in*2;
end
b=timestwo(a)
Error: File: Untitled Line: 8 Column: 1
Function definitions in a script must appear at the end of the file.
Move all statements after the "timestwo" function definition to before the first local function
definition.
3 Commenti
madhan ravi
il 31 Lug 2020
It is how it’s programmed. It’s like asking why walking forward than walking backward?
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!