I use anonymous functions for diagnostic printing when debugging in MATLAB. E.g.,
debug_disp = @(str) disp(str);
debug_disp('Something is up.')
...
debug_disp = @(str) disp([]);
% diagnostics are now hidden
Using disp([])
as a "gobble" seems a bit dirty to me; is there a better option? The obvious (?) method doesn't work:
debug_disp = @(str) ;
This could, I think, be useful for other functional language applications, not just diagnostic printing.