Prevent mlint warning for onCleanup like return value
I wrote a function, similar to onCleanup. I noticed that Matlab does not give a mlint warning for the following code.
dummy = onCleanup( @() some_func );
But for my own function
dummy = MyOwnCleanup( @() some_func );
I get the warning Value assigned to variable might be unused, which I need to silence with %#ok<NASGU>. Obviously, Matlab recognizes the onCleanup call and does not emit a warning. How can I acchieve similar behaviour for my own MyOwnCleanup function?I wrote a function, similar to onCleanup. I noticed that Matlab does not give a mlint warning for the following code.
dummy = onCleanup( @() some_func );
But for my own function
dummy = MyOwnCleanup( @() some_func );
I get the warning Value assigned to variable might be unused, which I need to silence with %#ok<NASGU>. Obviously, Matlab recognizes the onCleanup call and does not emit a warning. How can I acchieve similar behaviour for my own MyOwnCleanup function? I wrote a function, similar to onCleanup. I noticed that Matlab does not give a mlint warning for the following code.
dummy = onCleanup( @() some_func );
But for my own function
dummy = MyOwnCleanup( @() some_func );
I get the warning Value assigned to variable might be unused, which I need to silence with %#ok<NASGU>. Obviously, Matlab recognizes the onCleanup call and does not emit a warning. How can I acchieve similar behaviour for my own MyOwnCleanup function? mlint, oncleanup MATLAB Answers — New Questions