return -2 : is there a clean way to exit parent function from a nested function?
Show older comments
I have a parent function and several nested functions. I would like to be able, in a nested function instead of doing "return" and go back to the parent function, to do some kind of "return-2" and also exit the parent function (not only the nested one).
Is there a clean way to do it?
(I know that I can use some "flag" variable, and then in the parent function have each time "if flag; return", but I want to avoid to have duplicated code, if possible.)
2 Comments
Geoff Hayes
on 15 Jan 2015
Jonas - do you mean nested function or nested loop?
Jonas
on 15 Jan 2015
Accepted Answer
More Answers (0)
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!