Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Joe Canner <jcanner1@jhmi.edu> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | st: RE: return null Mata |
Date | Tue, 1 Apr 2014 20:46:52 +0000 |
Anthony, According to the Mata help, " return [without any arguments] causes the function to stop execution and return to the caller, returning nothing." Is that what you wanted? Regards, Joe Canner Johns Hopkins University School of Medicine -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Thomas, Anthony Sent: Tuesday, April 01, 2014 4:41 PM To: statalist@hsphsun2.harvard.edu Subject: st: return null Mata Hi All, I'm sure there is an obvious answer to this question, but I can't seem to figure it out. I have a Mata function that I want to return nothing when some condition fails to be met (the function is ordinarily supposed to return a string matrix). I was thinking something like: if(something) return(NULL); or if(something) return(0); would work, but I get errors indicating the return type is not as expected in either case. I'm guessing this is because NULL is really a pointer and 0 is just being interpreted in its normal sense. How can I get Mata to return nothing in one instance and a string matrix in others? Thanks, Anthony * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/